Introduction to Spatial Data Science
The textbook for GEOG 215
Preface
This book is an open-educational resource textbook for designed for my course, GEOG 215, Introduction to Spatial Data Science, built from the course lectures.
Every chapter is a runnable Quarto document. The R code in each chapter runs when the book is built, so the tables and maps you see come from the code printed beside them.
About this book
This is an interactive textbook specifically designed and written for GEOG 215. It’s designed for students new to R and new to spatial data. Students are expected to have some experience with math and/or statistics.
How this book is organized
The chapters are grouped into six units. Each unit opens with a page that summarizes its chapters.
Unit 1: R and Spatial Data Science (Chapters 1–5) sets up everything else. It explains what spatial data science is and why location matters, then gets you working in R, RStudio, and R Markdown, with R’s basic building blocks: vectors, data types, and data frames. It ends with if statements, loops, and writing your own functions, so you can make decisions and repeat work in code.
Unit 2: Into the Tidyverse (Chapters 6–9) introduces the tidyverse. Working with a year of flights from New York’s airports, you learn the dplyr verbs that filter, sort, select, change, and summarize data, chained together with the pipe, and then turn the results into graphs with ggplot2.
Unit 3: Maps and Geographic Data (Chapters 10–14) moves from graphs to maps. You make thematic maps of the UNC campus with tmap, then step back to see how the real world becomes geographic data: the vector and raster data models, the file formats that store them, and the datums, coordinate systems, and map projections that give every feature its location. It ends by getting geographic data from the places that publish it: the US Census Bureau, through the APIs that let your code download its data directly, and the ArcGIS servers that publish many government GIS layers.
Unit 4: Spatial Analysis (Chapters 15–17) starts to analyze spatial data. You join tables by a shared column and by location, explore variables with descriptive statistics, plots, and maps, and describe where features are with spatial statistics such as the mean center. Along the way you put your own R functions to work.
Unit 5: Statistics and Science (Chapters 18–22) turns data into evidence. You compare groups with p-values and ANOVA, model relationships with linear regression, and put it all together in a reproducible spatial data science project. It ends by asking whether near things are more related than distant things: you measure distance, define neighbors and weight matrices, and test for clustering and hot spots with the Average Nearest Neighbor ratio, Moran’s I, and Getis-Ord Gi*.
Unit 6: Next Steps (Chapters 23–24) looks beyond the course. You turn your maps into interactive dashboards with leaflet, flexdashboard, crosstalk, and Shiny, and then look at where spatial data science is used, the advanced topics that build on this book, such as remote sensing, space-time modeling, and GeoAI, and the UNC courses and careers that come next.
Acknowledgments
I’d like to thank the work of Drs. Julia Cardwell, Paul Delamater, Paul Tailie, and Conghe Song for their support. I want to thank the Teaching Assistants Jacob Tafrate, Braulio Lahuatte, Najila Porno, Ngyuen Tien Anh Quach, Sophia Alhadeff, Andrew Robinson, and Cameron Brousse. I’d like to thank my Undergraduate Learning Assistants, Harvey Chen, Rachel Johnson, and Esther Zhu. Finally, I’d like to acknowledge the hard work of my students, without whom, this would not be possible.