Joins & relationships
Spatial joins, attribute joins, nearest neighbour and point-in-polygon.
Everything on Spatial Workflow about joins & relationships, in the order that usually works: understand the idea, then run the task, then fix it when it goes wrong. 48 guides in total.
16 learning paths run through this topic — follow one if you would rather work through a route than pick a single guide.
🧭 Start with the concepts
The ideas the how-to guides below assume you already have.
- Spatial Indexes Explained: R-trees and Why Spatial Joins Are Fast spatial index r-tree explained
- Spatial Predicates Explained: Intersects, Within, Contains and the Rest spatial predicates geopandas
- Spatial Join Cardinality Explained: One-to-One, One-to-Many and What to Do spatial join one to many
- Nearest-Neighbour Joins Explained: Distance, Ties and Search Radius nearest neighbour join explained
- Attribute Join or Spatial Join? Choosing How to Combine Two Layers attribute join vs spatial join
- Spatial Clustering Explained: DBSCAN, K-Means and What They Assume spatial clustering explained
- Network Distance vs Straight-Line Distance Explained network distance vs straight line
- Census Identifiers Explained: GEOIDs, Codes and the Leading Zero Problem census geoid explained
⚙️ Then do the task
Step-by-step walkthroughs with code you can copy and adapt.
- How to Filter Spatial Data in Python Using GeoPandas filter geopandas data
- How to Join Attribute Data to a GeoDataFrame in Python join attribute data geopandas
- How to Count Points in Polygons with GeoPandas count points in polygon geopandas
- How to Find the Nearest Point in GeoPandas nearest point geopandas
- How to Aggregate Spatial Data by Region in GeoPandas aggregate spatial data geopandas
- How to Select Features by Location in GeoPandas select by location geopandas
- How to Perform a Spatial Join in Python (GeoPandas) spatial join geopandas
- How to Fuzzy-Match Place Names When Joining Spatial Data in Python fuzzy match place names python
- How to Run Spatial SQL Queries from Python with PostGIS spatial sql query python postgis
- How to Merge Near-Duplicate Features in a Spatial Dataset merge near duplicate features python
- How to Enrich Many Files Against One Reference Layer batch spatial join reference layer
- How to Calculate Zonal Statistics in Python zonal statistics python
- How to Do a Spatial Join in PostGIS with SQL postgis spatial join sql
- How to Use the Spatial Index Directly in GeoPandas (sindex) geopandas sindex spatial index
- How to Bin Points into Hexagons in Python hexbin points python
- How to Cluster Points by Location with DBSCAN in Python dbscan spatial clustering python
- How to Calculate Moran's I in Python morans i python
- How to Snap Points to a Street Network in Python snap points to network python
- How to Aggregate Movement into Flows Between Zones aggregate movement flows python
- How to Interpolate to Polygons Instead of a Grid areal interpolation python
- How to Reverse Geocode Points to Addresses and Areas in Python reverse geocode python
- How to Run a Spatial Join in DuckDB duckdb spatial join
- How to Extract a Time Series per Polygon from a NetCDF Grid netcdf zonal statistics polygons time series
- How to Assign Points to H3 Cells in Python h3 python points to cells
- How to Join Two Point Datasets on an H3 Index Instead of a Spatial Join join on h3 index
- How to Join a Census Table to Its Boundaries Without Losing Rows join census data to shapefile python
- How to Aggregate Survey Estimates and Their Margins of Error aggregate acs margin of error python
- How to Compare Census Years Across Changed Boundaries census crosswalk python
- How to Count the Population Within Reach of Each Facility population within distance of facility python
- How to Measure Distance to the Nearest Facility for Every Home distance to nearest facility python
- How to Summarise Catchment Attributes: Area, Slope and Land Cover catchment characteristics python
- How to aggregate points to units that meet a minimum count aggregate points minimum count
🔧 When it breaks
The errors this topic produces, with the cause explained rather than just the command.
- Spatial Join Returns Empty Results in GeoPandas: How to Fix It spatial join empty geopandas
- GeoPandas Merge Returns NaN or No Matches: How to Fix It geopandas merge no matches
- GeoPandas "Columns Overlap but No Suffix Specified" Error: How to Fix It columns overlap but no suffix specified
- GeoPandas Spatial Join Returns Duplicate Rows: How to Fix It geopandas spatial join duplicates
- DBSCAN Returns One Giant Cluster or Labels Everything Noise dbscan one cluster
- Spatial Weights Warn About Islands or Moran's I Returns nan spatial weights islands warning
- Fixing Census Joins That Fail Because Leading Zeros Were Dropped census geoid leading zeros join fails
- Fixing Census Data That Does Not Match the Boundary File Year census data boundaries mismatch year
Learning paths through this topic
A curated route rather than a list — the guides in the order that builds on itself.
-
Spatial Statistics
Measure the pattern instead of eyeballing the map.
Open path → -
Networks & Routing
Distance along the street, not across the rooftops.
Open path → -
Raster Analysis
Read, reproject, clip and summarise raster data in Python.
Open path → -
Spatial SQL & PostGIS
Move the heavy lifting from Python into the database.
Open path → -
GIS Data Cleaning
Turn messy spatial data into analysis-ready datasets.
Open path → -
Batch Processing
Process many files at once, reliably.
Open path → -
Movement & Time
Tracks are not points — the order and the clock are the data.
Open path → -
Interpolation & Surfaces
A continuous surface from scattered samples, with its support attached.
Open path → -
Geocoding & Addresses
Address text is data too — and it is the messiest data in the file.
Open path → -
DuckDB for Spatial Data
A spatial database with no server, reading the file you already have.
Open path → -
Gridded & Climate Data
A raster with a time axis, a calendar and forty years in one file.
Open path → -
H3 & Global Grids
Give every point a cell id and half the geometry work becomes a join.
Open path → -
Census & Demographics
The most-used open data there is, and the easiest to map wrongly.
Open path → -
Location & Accessibility
Who can reach what — and where the next site should go.
Open path → -
Hydrology & Watersheds
A DEM already knows where the water goes. Ask it carefully.
Open path → -
Geoprivacy & Anonymisation
A coordinate is an identifier. Release it as if it were one.
Open path →
Related topics
Subjects that keep coming up alongside this one, most overlap first.