Spatial analysis
Spatial analysis is the set of methods for studying data tied to places on a map. It ranges from looking at maps and finding the best route or site to measuring patterns and building prediction models.[1] Its statistical part, spatial statistics, applies Statistics to such data and is the focus of this page.[1]
Examples of such data include:[2]
- disease cases in a city
- soil samples across a field
- house prices in neighbourhoods
- trees in a forest
These methods are used in many fields:[2]
- environmental science
- public health
- ecology
- farming
- urban planning
- economics
The field rests on one observation: nearby places tend to have similar values. Ordinary statistics usually treats observations as independent, meaning that knowing one value tells you nothing about the others. Spatial analysis gives tools to measure how values depend on location, to predict values at places that were not measured, and to avoid mistakes that come from ignoring location.[3]
Why location matters
The best-known statement of the idea is Tobler's first law of geography: "everything is related to everything else, but near things are more related than distant things." Waldo Tobler wrote it in 1970, in a paper describing a computer simulation of population growth in Detroit.[4][5]
Spatial autocorrelation is the name for this tendency. It measures how much the values of one variable at nearby places tend to go up and down together.[5]
- Positive spatial autocorrelation means similar values sit close together, forming clusters.
- Negative spatial autocorrelation means neighbours tend to differ, so values are spread out like a checkerboard.
- No spatial autocorrelation means values are arranged at random.
Positive autocorrelation is by far the most common kind in real data. Its usual strength depends on the type of data.[3]
| Data type | Typical positive autocorrelation |
|---|---|
| Social and economic data | Moderate |
| Satellite images | Strong |
This matters because nearby values repeat part of the same information. A satellite image with hundreds of thousands of pixels may hold as much independent information as only a few hundred independent samples. Methods that assume independence then overstate how sure they are.[3]
A second issue is spatial heterogeneity, where the relationship between variables itself changes from place to place. A single model fitted to the whole map can hide this. Local models, such as geographically weighted regression, fit a separate model at each place instead.[6]
Kinds of spatial data
Spatial data are usually treated as observations of a random process, a set of uncertain values that can differ from place to place:
where is a location, is the set of possible locations, is usually 2 (a flat map), and is the value observed at . Noel Cressie's textbook sorts spatial data into three types by the nature of .[2][7]
| Type | What the set of locations is | Example | Typical question |
|---|---|---|---|
| Areal (lattice) data | A fixed, countable set of areas or grid cells, regular or irregular | Sudden infant deaths per county in North Carolina, 1974; grid cells of a satellite image | Which areas have high values, and why? |
| Geostatistical data | A fixed, continuous region; values exist everywhere but are measured at sample sites | Topsoil lead at sample sites near the river Meuse; air pollution at monitoring stations | What is the value at places that were not sampled? |
| Point patterns | Random; the locations themselves are the data | Forest fires; home addresses of people with a disease | Are the points random, clustered, or evenly spaced? |
Areal data, also called lattice data, are values recorded for a fixed set of areas or grid cells. They often come from counting events within administrative areas, such as disease cases per district. Satellite data on a regular grid of cells are also areal data.[2]
A map stored this way, as a grid of cells that each hold a value, is called a raster.
Beyond these three types, spatial data also include:[2]
- Spatio-temporal data, which change over time as well as space and are studied in spatiotemporal statistics.
- Flows, such as counts of people travelling between places.
Operations in GIS
Much practical spatial analysis is done in a geographic information system (GIS).
Buffers and overlay
Two of the simplest GIS operations work on map shapes.
- Buffer analysis creates polygons (closed, flat shapes with straight sides) around points, lines, or polygons out to a given distance.[8]
- Overlay combines layers to find features at the same locations, for example land parcels that fall inside a buffer around a river.
Vector data store map features as points, lines, or shapes, rather than as grid cells. Tomlin noted that vector systems had long offered overlay under the name "polygon overlay".[9]
Map algebra
Map algebra is a set of operations on raster layers developed by C. Dana Tomlin. The term was introduced in the late 1970s with his Map Analysis Package, and Tomlin regrouped its operations in 1983 and refined them in 1990.[9] It has four main kinds of operation.[10]
- Local: each output cell depends only on the same cell in one or more inputs.
- Focal: each output cell depends on a neighbourhood around the cell, most often 3 by 3 cells.
- Zonal: each output cell depends on all cells in the same zone. Zones can have any shape and need not be connected.
- Global: each output cell can depend on every cell, as in distance calculations.
Topological relations
Geospatial topology describes how shapes relate, such as touching, overlapping, or containing. The DE-9IM (Dimensionally Extended 9-Intersection Model) records how two shapes interact by comparing their interiors, boundaries, and exteriors in a 3 by 3 matrix.[11]
Neighbours and spatial weights
Measuring spatial autocorrelation in areal data starts with a rule for which areas count as neighbours. The rule depends on the variable and the setting.[12]
- Contiguity: areas are neighbours if they share a border. Under the "queen" rule, sharing even a single corner point is enough.
- nearest neighbours: each area's neighbours are the areas closest to it.
- Distance band: areas are neighbours if they lie within a set distance of each other.
The chosen rule is stored in a spatial weights matrix . Its entry links area to area , with more weight for closer areas, and is set to 0. For contiguity, if areas and share a border and 0 otherwise.[12]
Two common ways to set the weights are:[12]
- Row-standardised weights: each of an area's neighbours gets an equal share, .
- Inverse-distance weights: nearer neighbours get more weight.
The weighted average of an area's neighbouring values is called its spatial lag.[5]
Measuring spatial autocorrelation
Moran's I
Moran's I, introduced by Patrick Moran in 1950, is one of the two most common measures of spatial autocorrelation for areal data. It compares each area's deviation from the mean with its neighbours' deviations.[5]
Here is the number of areas, is the value in area , is the mean of all values, and are the spatial weights. The formula needs at least one nonzero weight and values that are not all equal.[5]
If there is no spatial autocorrelation, the expected value of is , which is close to 0 for large . Values of usually lie between and .[5]
- well above means positive autocorrelation (clustering).
- well below it means negative autocorrelation (dispersion).
- near it means no spatial pattern.
A test of significance asks whether the observed could easily arise by chance. It is done in one of two ways.[5]
- z-score test: compute minus its expected value, divided by its standard deviation (a measure of how far values typically lie from their average). Compare this with the bell-shaped normal distribution.
- Permutation test: shuffle the observed values among the areas many times, recompute each time, and see how often the shuffled values are as extreme as the real one.
For example, median house prices in 506 Boston census tracts in 1978 give , against an expected value of about . The test rejects the hypothesis of no autocorrelation, so the prices are clearly clustered.[5]
Moran scatterplot
The Moran scatterplot plots each area's standardised value (its distance from the mean, in standard deviations) against its spatial lag.[5] With row-standardised weights, the slope of the trend line through the points equals Moran's I.[3]
Other global measures
Several other statistics measure association over the whole map.
- Geary's C, introduced by Roy Geary in 1954, is the other common index for areal data.[5]
- The join count statistic is the usual choice for binary data, coded 0 and 1. It counts pairs of neighbours that are 1 and 1, 0 and 0, or 0 and 1. Many same-value joins point to positive autocorrelation; many mixed joins point to negative autocorrelation.[13]
- The Mantel test, from Nathan Mantel in 1967, measures the correlation between two distance matrices, such as geographic distance and genetic distance. It tests significance with random permutations.[14]
Local indicators
A single global number can hide where the clusters are. Local indicators of spatial association (LISA), proposed by Luc Anselin in 1995, give one value per area. Their sum is a multiple of the matching global statistic.[5]
The local Moran's I for area is
A positive means area is surrounded by similar values. A negative marks an outlier that differs from its neighbours.[5]
Local Moran's I is used to find each geographical cluster. Areas with significant local values are sorted into four types, matching the quadrants of the Moran scatterplot.[5]
- High-high: a high value among high neighbours.
- Low-low: a low value among low neighbours.
- High-low: a high value among low neighbours.
- Low-high: a low value among high neighbours.
Point pattern analysis
Point pattern analysis studies the locations of events, such as trees, crimes, or disease cases. The points are called events to tell them apart from arbitrary points on the map.[15]
Complete spatial randomness
The baseline model is complete spatial randomness (CSR). Under CSR, an event is equally likely to occur anywhere in the study area, independent of other events. This is the homogeneous Poisson point process.[16]
Real patterns are compared with CSR in two directions.[16]
- Regular patterns have more space between points than CSR, for example because of competition.
- Clustered patterns have more grouping than CSR, for example because of reproduction with limited spread or because conditions vary across the area.
Quadrat counts
The simplest test of CSR divides the area into equal quadrats and counts the points in each. Under CSR, each quadrat should hold about the same number of points.[16]
Here is the total number of points and is the count in quadrat . A value near 0 suggests a regular pattern, and a large value suggests clustering.[16]
Under CSR, follows a chi-squared distribution, the standard reference for how far observed counts stray from expected counts. It has degrees of freedom, the number of counts that can vary once their total is fixed.[16]
For 71 pine trees in a Swedish forest plot split into 12 quadrats, . The p-value, the chance of a result at least this extreme if the pattern were CSR, is about 0.5, so there is no evidence against CSR.[16]
The method has two weaknesses. Results can change with the quadrat layout, and it tests the whole pattern at one scale only.[16]
Ripley's K function
Ripley's K function looks at clustering across many distances at once. Brian Ripley set out its theory in a 1976 paper on stationary point processes, whose statistical behaviour is the same everywhere in the study area.[17]
Here is the intensity, the expected number of events per unit area. Under CSR, . For a given distance, indicates clustering and indicates a regular pattern.[18]
In practice, analysts estimate from the data and compare it with a simulation envelope. This is a band showing the range of values from many simulated CSR patterns.[18]
Points near the edge of the study window are a problem, because events just outside the window are not seen. The simple count of neighbours within distance is therefore biased low.[18]
Edge-corrected estimators fix this. They weight each pair by one divided by the share of the circle around the event that lies inside the window.[18]
Clustering among cases and controls
Case-control tests compare the locations of disease cases with those of controls chosen from the same population. This lets them account for uneven population density and for confounders, other factors that could affect the comparison between cases and controls.[19]
The Cuzick-Edwards test, published in 1990, does this with nearest neighbours. Its statistic is the sum, over all cases, of how many of each case's nearest neighbours are also cases.[19]
Geostatistics
Geostatistics deals with values that vary continuously over a region, such as ore grade, rainfall, or soil pollution. The French mining engineer Georges Matheron named the field.[20]
Stationarity
Geostatistical models assume some form of stationarity, meaning the statistical behaviour does not change across the region.[21]
Under second-order stationarity, the mean is constant. The covariance between two locations, a measure of how their values vary together, depends only on the vector between them, that is, on the distance and direction from one to the other.[21]
If the covariance depends only on the distance and not on direction, the process is called isotropic. Otherwise it is anisotropic.[21]
The variogram
The Variogram describes how dissimilar values become as the distance between locations grows. A process is intrinsically stationary if its mean is constant and
for all pairs of locations. Here is the variance, the average squared difference from the mean. The function is the semivariogram, and its value is called the semivariance.[21]
The semivariance is estimated from the data as half the average squared difference between values at pairs of sites:
where is the set of pairs of sample sites separated by and is how many pairs there are. Plotted against distance, this measured semivariogram shows the continuity and spatial variability of the process.[21]
A typical semivariogram has three features.[21][22]
- Range: the distance beyond which the curve levels off. Points farther apart than this are roughly uncorrelated.
- Sill: the near-constant value the curve reaches beyond the range.
- Nugget: a jump at distance zero. It is often put down to measurement error but can also indicate a process that is not continuous in space. The partial sill is the sill minus the nugget.
Interpolation
Interpolation predicts values at places that were not sampled. The simplest method gives each place the value of its closest sample, which divides the map into a Voronoi diagram.[23]
Inverse distance weighting (IDW) uses a weighted average of all samples, with closer samples weighted more.[23]
Here is the prediction site, is its distance to sample , and the power sets how strongly nearer samples are favoured. The formula applies where is not itself a sample site, so that every .[23]
Kriging also predicts with a weighted sum of samples, but takes its weights from a variogram fitted to the data. Nearby, correlated samples get more weight, and samples bunched together in one spot get less, since they carry overlapping information.[22]
Under its assumptions, kriging gives the best linear unbiased prediction. Unbiased means it is right on average. Among such linear methods, it has the smallest mean squared error, the average squared difference between predicted and true values.[22][20]
Kriging also gives a measure of uncertainty for each prediction.[22][20]
| Variant | Assumption about the mean |
|---|---|
| Simple kriging | Known mean |
| Ordinary kriging | Constant but unknown mean |
| Universal kriging | Mean that changes across the region |
Models for areal data
Areal data are often modelled by letting each area's value depend on its neighbours. In a conditional autoregressive (CAR) model, the distribution of an area's value, given all the others, depends only on its neighbours.[24]
The intrinsic CAR model sets
where is the set of neighbours of area , is how many there are, and is their mean. The model pulls each area towards its neighbours' average.[24]
The Besag-York-Mollié (BYM) model of 1991 adds a CAR term to a regression, together with an independent noise term. It is widely used for disease mapping within Bayesian hierarchical models.[24]
Origins
Julian Besag's 1974 paper was a foundation for spatial autoregressive models. Besag, together with Andrew Cliff and Keith Ord, built on work by Peter Whittle and others to set out these models.[3]
Regression models with spatial dependence are also central to spatial econometrics. Jean Paelinck coined that term in 1974.[3]
Regression that varies over space
Geographically weighted regression (GWR) lets the coefficients of a regression change with location. Coefficients are the numbers that say how strongly each input variable is linked to the outcome. GWR was introduced in 1996 by Chris Brunsdon, Stewart Fotheringham, and Martin Charlton.[25]
Here is the location of observation , are the predictors (the input variables used to predict ), and each is a coefficient that depends on location.[26]
At each location, GWR fits a weighted least squares regression, with weights that fall off with distance:[26][25]
is a diagonal matrix for location , meaning it has values only along its main diagonal. Here those values are the weights given to each observation. The matrix must be invertible.[26]
The weights come from a kernel, a function that turns distance into a weight. The most common kernels are:[25]
- bisquare
- Gaussian
- exponential
A bandwidth controls how quickly the weights fall off with distance. It can be set in two ways:[25]
- A fixed kernel uses the same distance for every location.
- An adaptive kernel uses a set number of nearest neighbours, so it widens where data are sparse.
A small bandwidth points to local processes, and a large one to regional or global processes.[25]
Multiscale GWR, from 2017, allows each predictor its own bandwidth.[25]
Pitfalls
The modifiable areal unit problem
The modifiable areal unit problem (MAUP) is that results from areal data depend on how the areas were drawn. Stan Openshaw's 1984 book described the areal units used in many studies as "arbitrary, modifiable, and subject to the whims and fancies of whoever is doing, or did, the aggregating."[27]
Openshaw split the problem into two parts.[27]
- The scale effect: results change as small units are merged into fewer, larger units.
- The zoning effect: results change when units are grouped in different ways at the same scale.
The effect can be large. Openshaw studied two variables for Iowa's 99 counties, the 1968 Republican vote share and the share of people over 60. Grouping the counties into 6 connected regions gave correlations anywhere from about to , against 0.34 for the counties themselves.[27]
The modifiable temporal unit problem is the same issue for time. Results can change with the length of the time intervals, where the intervals start, and where the series begins and ends.[28]
The ecological fallacy
The ecological fallacy is assuming that results from grouped data also hold for the individuals in the groups. For example, a link between two rates across counties need not hold for the people living in them.[27]
Edge effects
Study areas have borders, but the processes behind the data do not stop there. Statistics such as the K function are biased near the edge unless they are corrected.[18]
History
Mapping disease to find its cause is an old idea. John Snow's map of cholera deaths around the Broad Street pump in London is the best-known example.
Snow gathered data on 616 deaths between 19 August and 30 September 1854. His map marked 574 of them, because some addresses were unknown.[29][30]
Historians argue that Snow did not use the map to find the pump. Instead, it illustrated an argument he had already made after looking into 83 deaths in early September.[30][29]
A later version of the map added a line around the area that was closer, in walking distance, to the Broad Street pump than to any other pump. This line is an early form of a Voronoi diagram.[30]
Formal methods followed in the 20th century.
- 1914 to 1934: William Gosset ("Student"), Udny Yule, and Frederick Stephan noted that spatial dependence distorts ordinary statistics.[3]
- 1950 and 1954: Moran, Geary, and Whittle published the founding papers on spatial autocorrelation.[3]
- 1951: Danie Krige published a paper, based on his master's thesis, on estimating gold grades in South Africa. It contained the first elementary use of what is now called kriging.[31]
- Late 1950s and 1960s: Pierre Carlier coined the French term krigeage in Krige's honour, and Matheron put the English form kriging into print and built the theory of geostatistics.[20]
- 1970: Tobler stated his first law of geography.[4]
- Early 1970s: Cliff and Ord made spatial autocorrelation a mainstream research topic.[3]
- 1974: Besag published his work on lattice models, and Paelinck coined the term spatial econometrics.[3]
- 1976: Ripley published the theory behind the K function.[17]
- 1984: Openshaw described the modifiable areal unit problem.[27]
- 1991: Cressie's Statistics for Spatial Data brought geostatistical, lattice, and point-pattern methods together in one book.[3][7]
- 1995 and 1996: Anselin introduced LISA, and Brunsdon, Fotheringham, and Charlton introduced GWR.[25]
Software
Much spatial statistics is done in the R language, through packages built for each data type.[5][18][22][24]
- spdep: neighbour lists, spatial weights, and Moran's I.
- spatstat: point patterns, quadrat tests, and the K function.
- gstat: variograms, IDW, and kriging.
- R-INLA: Bayesian models such as CAR and BYM.
References
- The Language of Spatial Analysis, Esri Press, 2013.
- Types of spatial data, in Spatial Statistics for Data Science: Theory and Practice with R, Paula Moraga, Chapman & Hall/CRC, 2023.
- Spatial Autocorrelation (FC-05-037), UCGIS GIS&T Body of Knowledge, 2020.
- Tobler's First Law of Geography, Nigel Waters, International Encyclopedia of Geography, 2017.
- Spatial autocorrelation, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- The GWR route map: a guide to the informed application of Geographically Weighted Regression, Comber et al., arXiv, 2020.
- Statistics for Spatial Data, Revised Edition, Noel Cressie, Wiley, 1993.
- Buffer (Analysis Tools), Esri ArcGIS Pro documentation, 2024.
- Map algebra: one perspective, C. Dana Tomlin, Landscape and Urban Planning, 1994.
- Types of operations in Spatial Analyst, Esri ArcGIS Pro documentation, 2024.
- Dimensionally Extended 9-Intersection Model, Introduction to PostGIS workshop, 2024.
- Spatial neighborhood matrices, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Operational Local Join Count Statistics for Cluster Detection, Luc Anselin and Xun Li, Journal of Geographical Systems, 2019.
- Testing the Mantel statistic with a spatially-constrained permutation procedure, Crabot et al., Methods in Ecology and Evolution, 2019.
- Spatial point patterns, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Complete spatial randomness, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- The second-order analysis of stationary point processes, B. D. Ripley, Journal of Applied Probability, 1976.
- The K-function, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Cuzick and Edwards' test when exact locations are unknown, Geoffrey M. Jacquez, American Journal of Epidemiology, 1994.
- Kriging: Understanding allays intimidation, Ricardo A. Olea, U.S. Geological Survey, 1996.
- Geostatistical data, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Kriging, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Spatial interpolation methods, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- Bayesian spatial models, in Spatial Statistics for Data Science, Paula Moraga, Chapman & Hall/CRC, 2023.
- The Geographically Weighted Regression Framework (AM-03-034), UCGIS GIS&T Body of Knowledge, 2020.
- Geographically Weighted Regression (GWR), de Smith, Goodchild and Longley, Geospatial Analysis online, 2024.
- The Modifiable Areal Unit Problem (CATMOG 38), Stan Openshaw, Geo Books, 1984.
- Modifiable Temporal Unit Problem (MTUP) and Its Effect on Space-Time Cluster Detection, Tao Cheng and Monsuru Adepeju, PLOS ONE, 2014.
- Our sense of Snow: the myth of John Snow in medical geography, Kari S. McLeod, Social Science & Medicine, 2000.
- Map-making and myth-making in Broad Street: the London cholera epidemic, 1854, Howard Brody, Michael Russell Rip, Peter Vinten-Johansen, Nigel Paneth and Stephen Rachman, The Lancet, 2000.
- In memoriam: Professor D.G. Krige FRSSAf, South African Journal of Science, 2015.
