Spatial statistics
Density, clustering, hotspots and autocorrelation — measuring pattern rather than drawing it.
Mapping shows you a pattern. Statistics tells you whether the pattern is one. Those are different questions, and the second needs a null model: a clustered, a random and a regular point pattern can hold exactly the same number of points in exactly the same area, and no count per zone distinguishes them.
Two choices decide most results here and are usually left at their defaults. The first is the neighbourhood — contiguity, k-nearest, or a distance band — which is a hypothesis about how the process spreads, not a technicality; change it and Moran’s I changes with it. The second is the scale of analysis, because autocorrelation measured over census tracts and over counties are answers to different questions.
Below: the concepts cover density, autocorrelation, clustering and hotspots; the how-to guides compute them; and the fixes are the results that come back null, or significant for the wrong reason.
🧭 Start with the concepts
The ideas the how-to guides below assume you already have.
- The Modifiable Areal Unit Problem Explained
- Kernel Density Explained: What a Heatmap Actually Shows
- Spatial Clustering Explained: DBSCAN, K-Means and What They Assume
- Spatial Autocorrelation Explained
- The Variogram Explained: How Far Does a Measurement Reach
- Discrete Global Grids Explained: H3, S2, Geohash and Why Cells Beat Coordinates
Show every concept in this topic
- H3 Explained: How a Hexagonal Grid Indexes the Whole Earth
- Choosing an H3 Resolution: Cell Size, Counts and What Each Level Can Show
- Margins of Error Explained: Why Survey Estimates Need Their Uncertainty
- Small Numbers Explained: Why Rates in Small Areas Jump Around
- Gravity and Huff Models Explained: Predicting Where People Go
- Re-identification risk in spatial data explained
- Spatial k-anonymity explained
- Management zones explained
- Return periods and annual exceedance probability explained
- Sampling Bias in Occurrence Data Explained
- Biodiversity Metrics Explained
- Air Quality Indices Explained
- Building Density Measures Explained
- Deforestation Rates Explained
- Avoided Deforestation Explained
- Rainfall Return Periods Explained: How Rare Was That Storm?
- Disease Clusters Explained
- Crime Concentration Explained
- Crime Hotspot Methods Explained
- Crash Exposure and Rates Explained
- Population Grid Accuracy Explained
- House Price Index Methods Explained: Median, Mix-Adjusted, Repeat-Sales and Hedonic
- Hurricane Counts Before Satellites: Why the Early Record Runs Low
- EV Share of the Fleet Explained: Registered Stock Against Yearly Additions
- Speedtest Data Explained: Who Runs Tests and What the Averages Mean
⚙️ Then do the task
Step-by-step walkthroughs with code you can copy and adapt.
- How to Make a Point Density Heatmap in Python
- How to Bin Points into Hexagons in Python
- How to Cluster Points by Location with DBSCAN in Python
- How to Build a Distance Matrix Between Two Layers in Python
- How to Calculate Moran's I in Python
- How to Find Hotspots with Getis-Ord Gi* in Python
Show every how-to guide in this topic
- How to Build Spatial Features for a Machine Learning Model
- How to Fit a Variogram and Krige a Surface in Python
- How to Calculate a Climatology and Anomalies with xarray
- How to Take an Area-Weighted Mean over a Latitude–Longitude Grid
- How to Aggregate Points into H3 Hexagons and Map Them
- How to Use H3 Neighbours for k-Ring Smoothing and Buffers
- How to Aggregate Survey Estimates and Their Margins of Error
- How to Smooth Unstable Area Rates with Empirical Bayes in Python
- How to Estimate Market Share with a Huff Model in Python
- How to measure re-identification risk in a point dataset
- How to build management zones with clustering in Python
- How to analyse an on-farm strip trial in Python
- How to estimate b-value and completeness in Python
- How to aggregate events to route segments
- How to build a species richness grid
- How to correct richness for sampling effort
- How to Estimate Wind Energy with a Weibull Distribution
- How to Compute an Air Quality Index in Python
- How to Calculate Coverage and Floor Area Ratio in Python
- How to Measure Change from an Old Map in Python
- How to Build Rainfall IDF Curves in Python from a Gauge Record
- How to Test Whether a Migration Flow Is Really One-Way in Python
- How to Calculate Wildfire Season Statistics in Python
- How to Recreate John Snow's Cholera Map in Python
- How to Make a Kernel Density Map of Disease Cases in Python
- How to Find Disease Clusters With a Spatial Scan Statistic in Python
- How to Make a Wind Rose in Python
- How to Check Model Winds Against Station Observations in Python
- How to Map Crime Hotspots with Kernel Density in Python
- How to Test for Near-Repeat Burglary in Python
- How to Find Statistically Significant Crime Hotspots on a Hex Grid in Python
- How to Compare Arrest Rates Between Areas in Python
- How to Find Clusters of Fatal Crashes with DBSCAN in Python
- How to Build a Hedonic Price Model for Airbnb Listings in Python
- How to Build a Repeat-Sales House Price Index in Python
- How to Measure the New-Build Price Premium in Python
- How to Find Gaps in Street Tree Planting with Nearest-Neighbour Distances
- How to Relate Street Tree Health to Sidewalk Damage and Site Conditions
- How to Map Hail Reports by County: Sizes, Counts and the One-Inch Spike
- How to Chart Disaster Declarations Over Time by Incident Type
- How to Chart Electric Vehicle Growth from Monthly Registration Counts
- How to Rank the Most Common Restaurant Health Code Violations
- How to Measure Internet Speed Change Between Two Quarters
🔧 When it breaks
The errors this topic produces, with the cause explained rather than just the command.
- Your Heatmap Looks Wrong: KDE Bandwidth and Cell Size
- DBSCAN Returns One Giant Cluster or Labels Everything Noise
- Spatial Weights Warn About Islands or Moran's I Returns nan
- My Kriging Fit Fails or Returns a Flat Surface
- Fixing an H3 Map That Misleads: Unequal Cell Areas and Empty Cells
- Fixing a Rate Map Dominated by Tiny, Nearly Empty Areas
Show every fix in this topic
- Fixing a Gravity Model That Sends Everyone to the Biggest Store
- Geomasking changed the result of the analysis
- The 1-in-100-year flood happened twice in ten years
- A richness map is a map of sampling effort
- Wind Energy from the Mean Speed Is Wrong
- AQI Averaged the Wrong Way
- Why Is My Average Wind Direction Wrong?
- Why Does My Crime Rate for a Small Area Change So Much?
- Fixing House Price Averages Skewed by Outliers
- Average Internet Speed Comes Out Wrong: Weight Tile Averages by Tests
Learning paths through this topic
A curated route rather than a list — the guides in the order that builds on itself.
- Spatial Statistics
- Spatial Machine Learning
- Interpolation & Surfaces
- Gridded & Climate Data
- H3 & Global Grids
- Census & Demographics
- Location & Accessibility
- Geoprivacy & Anonymisation
- Agriculture & Crops
- Biodiversity & Species Data
- Linear Referencing
- Natural Hazards & Risk
- Air Quality Data
- Renewable Energy Siting
- Urban Morphology
- Forest Monitoring
Related topics
Subjects that keep coming up alongside this one, most overlap first.