Skip to main content

Unit 4: Spatial Analysis

This unit puts data together and starts to analyze it. It joins tables by a shared column and by location, then explores data the way an analyst first meets a new dataset: describing each variable’s center and spread, plotting its distribution, and mapping it. It ends with statistics that describe where features are, and puts your own R functions to work calculating them.

Chapter 15: Joins: Attribute and Spatial

A join combines tables by matching rows. This chapter covers dplyr’s inner, left, right, and full joins, naming the key with join_by(), and chaining joins across several tables. It explains cardinality, and why you should know it before you join. It then joins by location with sf’s st_join(), compares simple and summarized, inside and distance spatial joins, and shows why distances need a projected coordinate system.

Chapter 16: Exploratory Spatial Data Analysis

Before modeling data, get to know it. This chapter places exploratory data analysis in the data science workflow and adds the spatial question: how do values vary across space? It covers checking a data table, measures of central tendency (mean, median, mode) and dispersion (range, IQR, standard deviation), histograms, boxplots, and density plots, distribution shapes and outliers, and mapping rates rather than counts.

Chapter 17: Spatial Descriptive Statistics

Spatial descriptive statistics describe where features are. This chapter covers the mean center, the weighted mean center (including the U.S. center of population), the central feature, and the standard distance, each matched to the familiar statistic it extends. It then reviews writing functions in R, from a one-line addSeven() to a meanCenter() function for any layer of polygons.