Skip to content
AI.info

Unsupervised learning

Spatial and Geospatial Clustering

Cluster spatial events and regions using appropriate geometry, density, adjacency, and exposure-aware validation.

By the end you can

Visual

Spatial units require different modeling contracts

Points, trajectories, grids, and administrative regions encode different evidence. The unit is a modeling contract, not a storage format. A point event carries a coordinate and the positional error of whatever produced it. A polygon carries an area, a population and a set of neighbours. A trajectory carries order and direction, which neither of the others can express. Two of these cannot be clustered under the same distance function until you decide what closeness is meant to represent.

FigureHierarchy · 5 levels
  • Point events

    Locations of incidents, businesses, observations, or sensor detections.

    • Trajectories

      Ordered paths with speed, stops, direction, and repeated visits.

      • Raster or grid cells

        Regular spatial bins that support local features and imagery.

        • Polygons and regions

          Administrative or natural areas with area, population, and adjacency.

          • Spatiotemporal episodes

            Events linked by both geographic and temporal proximity.

The spatial unit determines which distances, exposures, and adjacency rules are legitimate.

Example

Spatial effects that can masquerade as clusters

A map should be read together with exposure and measurement processes. Two of the effects below have been measured, and the measurements are larger than most analysts assume.

A dot on a map is not a house. In 2003 Cayo and Talbot checked automated geocoding of 3,000 upstate New York residential addresses against aerial imagery, and found the error scales with emptiness: “Error was found to increase as population density decreased. In rural areas of an upstate New York study area, 95 percent of the addresses geocoded to within 2,872 m of their true location.” The same street-centreline method placed 95% of urban addresses within 152 m, and 95% of suburban addresses within 421 m. Geocoding the identical address list to residential property parcel points instead cut those three 95th percentiles to 21 m, 39 m and 195 m. The point on the map is not the household. It is the household plus a displacement that grows by an order of magnitude as you leave the city.

Aggregation is the same failure at a larger amplitude. The experiment that named the modifiable areal unit problem took two variables measured on the 99 counties of Iowa: the percentage vote for Republican candidates in the 1968 congressional election, and the percentage of the population over 60. Openshaw restates the result: “Openshaw and Taylor (1979) report a range of different correlations that can be produced for these variables when the 99 counties are aggregated into a number of arbitrary six zone aggregations; the values ranged from .26 for the congressional districts to .86 for a simple typology of Iowa into rural-urban types.” At the 99-county level the correlation is 0.34. Aggregations of the same 99 counties into 12 districts can be constructed giving −0.97, and others giving +0.99. Nothing in the data changed. Only the zones did.

  • Population exposure: More people create more recorded events even when individual risk is unchanged.
  • Geocoding bias: Positional error scales with sparseness — Cayo and Talbot put 95% of urban addresses within 152 m of truth but 95% of rural addresses only within 2,872 m, a gap that parcel-point geocoding closes to 21 m and 195 m.
  • Boundary truncation: A study border cuts through a real neighborhood and makes edge density appear lower.
  • Road barrier: Two points are physically close but separated by a river crossing or restricted access.
  • Administrative aggregation: Regional averages hide within-region variation — the same 99 Iowa counties yield 0.34 at county level, .26 to .86 across six-zone schemes, and anything from −0.97 to +0.99 across 12-district ones.

Every map of parameter estimates is misleading

Map a rate by area and sample size confounds it in both directions at once. Gelman and Price took this apart in 1999, under a title that concedes the whole point: All Maps of Parameter Estimates Are Misleading. Raw rates come first: “very high (and low) observed rates are found disproportionately in poorly-sampled areas”. Adjust for small-sample noise and the artifact does not vanish. It relocates — “the highest adjusted rates tend to be found disproportionately in well-sampled areas”. Then comes the sentence that should stop a hotspot map in its tracks: “spatial patterns occur in adjusted rates even if there is no spatial structure in the underlying parameters of interest”. Their models produce geography out of parameters that contain none.

Spatial density therefore combines event process, population at risk, measurement coverage, and geography. Raw coordinates alone rarely define the full problem. Before a dense region on a screen says anything about risk, it may be reporting where the people are, or where the sampling was thorough, or where the addresses happened to resolve.

A dense place is not automatically a high-risk place.

Comparison

Coordinate distance and network distance

Straight-line closeness can differ sharply from travel or process connectivity. And the coordinate system you measure it in is itself a choice with a published error budget. Most web maps hand you coordinates in EPSG:3857, “WGS 84 / Pseudo-Mercator”. The registry that maintains that code declines to recommend measuring in it. Its remark on the code reads: “Not a recognised geodetic system. Uses spherical development of ellipsoidal coordinates. Relative to WGS 84 / World Mercator (CRS code 3395) gives errors of 0.7 percent in scale and differences in northing of up to 43km in the map (21km on the ground).” The recorded scope is web mapping and visualisation. The recorded extent is World - 85°S to 85°N. Esri's own documentation states the same defect independently: “Therefore, the Web Mercator coordinate system is not conformal, and besides enormous area and distance distortions away from the equator, it also does not project rhumb lines as straight lines.” A neighbourhood radius expressed in metres in that system is not the same physical radius at every latitude. An epsilon tuned in one city is not the parameter you think you are using in another.

Against that background three notions of distance compete. Euclidean separation in an appropriate projected system is cheap and supports most standard algorithms, but it needs the right projection and units, and it ignores barriers. Great-circle separation on a sphere or ellipsoid approximation avoids the naive latitude–longitude error over larger extents. It needs a consistent coordinate order, and it still ignores travel constraints. Network or travel distance along roads, transit, rivers, or process links reflects accessible paths and can carry direction and cost. It depends on network freshness, and it is expensive at scale.

FigureComparison · 3 columns

Euclidean projected distance

Measures straight-line separation in an appropriate projected coordinate system.

  • Useful for local planar regions
  • Requires correct projection and units
  • Ignores barriers and road networks
  • Supports many standard algorithms

Great-circle distance

Measures surface separation on a sphere or ellipsoid approximation.

  • Useful across larger geographic extents
  • Avoids naive latitude–longitude Euclidean error
  • Still ignores travel constraints
  • Needs consistent coordinate order

Network or travel distance

Uses roads, transit, rivers, or process links.

  • Reflects accessible paths
  • Can include direction and cost
  • Depends on network freshness
  • May be expensive at scale

Analogy

Grouping towns on several maps

A physical map, a road map, and a population map put the same towns in different company. Towns can be close by air, far by road, or similar only after adjusting for residents.

A fourth map would have to carry sampling dependence, temporal change, administrative boundaries, and exposure. Those layers shape the grouping as much as distance does. The Iowa counties above are one dataset drawn on several such maps, and each one returns a different answer.

Choose the map whose notion of closeness matches the decision.

Key idea

Random train–test splits can overstate spatial stability

Nearby observations often share environment, infrastructure, and measurement artifacts. Randomly splitting points can place almost identical local conditions in both analysis and confirmation samples. The usual remedy is spatial blocks, region holdouts, or distance buffers, with block size chosen to reflect the dependence scale relevant to deployment.

That remedy is contested in the primary literature. A course that handed you the rule without the argument would be teaching half of it. In 2021 Wadoux and colleagues replied to Ploton et al. with a numerical experiment on large-scale above-ground biomass mapping. Standard cross-validation produced smaller bias than spatial cross-validation. Their abstract concludes: “We conclude that spatial cross-validation methods have no theoretical underpinning and should not be used for assessing map accuracy, while standard cross-validation is deficient in case of clustered data.” Their alternative is probability sampling and design-based inference.

Both sides are laid out by Meyer and Pebesma in Nature Communications: “Ploton et al. attribute this contradiction to the use of validation strategies that ignore spatial autocorrelation in the data, and argue in favor of using spatial cross-validation methods. Wadoux et al. argue that spatial cross-validation is not the right way to evaluate map accuracy.” Mahoney and colleagues note in 2023 that “Wadoux et al. (2021) demonstrated that spatial CV methods may be overly pessimistic when assessing map accuracy”, while arguing that spatial cross-validation remains appropriate for evaluating predictive models rather than map accuracy. That distinction is the operational takeaway. Decide first whether you are grading a model or grading a map. The two questions do not take the same validation design.

Spatial proximity creates dependence that ordinary random splits ignore.

Case

One forest-biomass model, two validations, opposite verdicts

The choice of validation method can decide the answer, and in 2020 someone measured by how much. Ploton and colleagues trained a random-forest biomass model on “a massive forest inventory dataset of 11.8 million trees in central Africa”, then validated it twice. Their abstract states the outcome without softening it: “A standard nonspatial validation method suggests that the model predicts more than half of the forest biomass variation, while spatial validation methods accounting for SAC reveal quasi-null predictive power.” Same model, same data, two opposite verdicts. The nonspatial figure would have passed any review. The difference lies not in the model but in whether near-identical neighbours were permitted to sit on both sides of the split. Whether their spatial validation is the right instrument for a map is itself disputed, as the callout above records. What is not disputed is that two defensible procedures disagreed about roughly half of the variance in the same fitted model.

Steps

Build an exposure-aware spatial clustering study

Geometry, denominator, adjacency, and validation must be designed together. Define the spatial unit and document its precision. Select projected, great-circle, network, or adjacency distance according to the process. Model exposure with population, traffic, operating time, sensor coverage, or opportunity denominators. Inspect boundary effects and geocoding uncertainty. Validate with block holdouts, future periods, field review, and alternative scale parameters.

Step 4 has a measurable answer rather than a caution. Change the street reference layer and the map moves. Hart and Zandbergen street-geocoded roughly 398,000 crime incidents recorded in 2007–08 by six US law-enforcement jurisdictions — Arlington TX, Albuquerque NM, Charlotte-Mecklenburg NC, Las Vegas NV, San Diego County CA and Tampa FL. They did it five times over, against five street reference layers: local government centreline files, ESRI StreetMap Premium/Tele Atlas, ESRI StreetMap Premium/NAVTEQ, ESRI StreetMap USA and Census 2009 TIGER/Line. On the 193,875 incidents that geocoded successfully to all five layers and to a corresponding parcel or address point, their final technical report to the National Institute of Justice records that “results show that the median error distance for all successfully street geocoded crime incidents ranges from a low of about 60 meters for the local centerline reference data to a high 81 meters for the StreetMap™ USA reference data”. Five percent of incidents were displaced by more than 244 m (NAVTEQ) to 412 m (Tele Atlas). Swapping one reference layer for another moves the input points of a hotspot map by tens to hundreds of metres, before any clustering happens.

Completeness moves as well, and it moves with the quality of the address you were given. Once addresses recorded only as an intersection or a 100-block were excluded, match rates ran from 83% (auto burglaries, drug offences, homicides) to 86% (robberies). Among addresses recorded only as intersections or 100-blocks, the local centreline file matched as many as 44% of robbery locations and as few as 8% of burglary locations. Which incidents reach the map is therefore a function of crime type. The peer-reviewed version of the same analysis states that “Match rates vary by reference data, input address quality, and crime type”, and that local street centreline files were “as good as – and in many cases superior to” commercial alternatives. Run step 4 concretely. Regeocode against a second reference layer, measure the displacement distribution and the change in match rate by category, and see whether your clusters survive it.

FigureProcess · 5 steps
  1. 1. Define spatial unit

    Choose event, trajectory, cell, polygon, or episode and document precision.

  2. 2. Select geometry

    Use projected, great-circle, network, or adjacency distance according to the process.

  3. 3. Model exposure

    Add population, traffic, operating time, sensor coverage, or opportunity denominators.

  4. 4. Inspect boundary effects

    Test study borders, geocoding uncertainty, and alternative aggregation units.

  5. 5. Validate spatially

    Use block holdouts, future periods, field review, and alternative scale parameters.

Spatial clusters mix process and observation

A geographic pattern can reflect behavior, infrastructure, exposure, reporting, or coordinate error. Clustering alone cannot separate those causes. Treat the output as a map of measured structure under declared geometry and denominators, and let field evidence and spatial holdouts determine whether the pattern travels beyond the sampled map.

Investigation is not where it ends, because acting on geographic clusters has itself been tested at scale. Braga and colleagues pooled 65 studies containing 78 experimental and quasi-experimental tests of hot spots policing in Campbell Systematic Reviews in 2019. Twenty-seven of the 65 studies used randomised experimental designs, and 38 used quasi-experimental designs. The Results section of their abstract states: “Sixty-two of 78 tests of hot spots policing interventions reported noteworthy crime and disorder reductions.” The random-effects mean effect size was small but statistically significant. The result at the cluster edge is the one a spatial analyst should carry, and it is the opposite of the folk expectation that the activity simply moves around the corner. The National Institute of Justice's summary of the same review states that “Focused police intervention at hot spot locations does not seem to result in the spatial displacement of crime into areas immediately surrounding targeted locations. Rather, crime control benefits seem to diffuse into proximate areas.” The boundary you draw around a cluster becomes the boundary of an intervention. What happens just outside it is an empirical question with a measured answer.

A cluster on a map is a starting point for investigation, not an explanation of place.

Key takeaways