Spatial Autocorrelation and Moran's I Explained

Spatial Autocorrelation and Moran’s I Explained

If I had to choose a single idea that explains why GIS exists as a separate discipline, I would choose this one: places that are close together tend to be similar. Rich neighborhoods sit beside rich neighborhoods. Wet soils border wet soils. Disease clusters, price clusters, pollution plumes, forest fires, even political opinions, all of them tend to show geography in their values. A statistician who ignores this is working with a broken assumption, because most classical methods assume that observations are independent. Spatial data rarely is.

The property has a name, spatial autocorrelation, and the most famous way of measuring it is a statistic called Moran’s I. These two ideas open the door to all of spatial statistics. In this guide I’ll explain them in plain language, show how to compute and read Moran’s I, introduce its local cousin, and point out the mistakes that make results meaningless.

For the broader picture of where this fits, read Spatial Statistics for GIS: Complete Guide.

Illustration: Moran's I is close to +1 for clustering, near 0 for randomness and close to -1 for a checkerboard pattern.
Moran's I is close to +1 for clustering, near 0 for randomness and close to -1 for a checkerboard pattern.

What Is Spatial Autocorrelation?

Autocorrelation means a variable is correlated with itself. In the spatial case, it means that the value of a variable at one location is related to its values at nearby locations.

There are three possibilities.

  • Positive spatial autocorrelation: similar values cluster together. High values are near high values, low near low. This is by far the most common situation in the real world.
  • Negative spatial autocorrelation: dissimilar values tend to be neighbors, like a chessboard of high and low. It’s rare, and usually points to competition or systematic spacing, such as shops that avoid locating next to each other.
  • No spatial autocorrelation (randomness): the values are scattered with no relation to location. Knowing a place’s neighbors tells you nothing about it.

Tobler’s First Law

The intuition comes from Tobler’s First Law of Geography: everything is related to everything else, but near things are more related than distant things. Spatial autocorrelation is the statistical measurement of that law.

Why it matters

  1. It is the phenomenon you want to study. Is crime clustered? Is poverty concentrated? Do pests spread locally? These are questions about spatial autocorrelation.
  2. It violates the assumptions of ordinary statistics. If neighboring observations are alike, your sample contains less independent information than its size suggests. Standard errors are too small, and tests become overconfident.
  3. It justifies spatial methods. Interpolation relies on it. Without autocorrelation, there would be no basis for estimating values at unsampled places. See Interpolation Methods (IDW, Kriging, Spline) Explained.
  4. It diagnoses your models. If the errors of a regression are spatially autocorrelated, the model is missing something.

Moran’s I: The Global Measure

Moran’s I, introduced by the statistician Patrick Moran in 1950, is the most widely used global measure of spatial autocorrelation. “Global” means it produces one number for the whole study area, answering the question: overall, is this variable spatially clustered, dispersed or random?

The intuition

Moran’s I compares each feature with its neighbors:

  • For each feature, it looks at how far the value is from the overall mean.
  • It multiplies this by how far each neighbor is from the mean.
  • If a feature and its neighbors are on the same side of the mean (both above or both below), the product is positive. If they are on opposite sides, it’s negative.
  • It averages these products over the whole map, scaled by the overall variance and the number of neighbor relationships.

It’s essentially a spatial version of a correlation coefficient, between a variable and the average of the same variable in neighboring places.

How to read the value

  • Values near +1 indicate strong positive spatial autocorrelation: clustering of similar values.
  • Values near 0 indicate a random pattern. Precisely, the expected value under randomness is slightly negative, equal to minus one over (n minus one), which is practically zero for a reasonable number of features.
  • Values near -1 indicate strong negative spatial autocorrelation: a dispersed, checkerboard-like pattern.

Remember that Moran’s I is not strictly bounded between -1 and +1, though in practice it usually falls within that range.

The z-score and the p-value

The index on its own doesn’t tell you whether the pattern is statistically significant. Tools therefore also report:

  • Expected index: what you would expect under randomness.
  • Z-score: how many standard deviations your observed index is from the expected one.
  • P-value: the probability of seeing an index this extreme if the values were randomly distributed over the locations.

A small p-value, commonly below 0.05, with a positive z-score, suggests significant clustering. With a negative z-score, significant dispersion. Large p-values mean you can’t reject randomness.

Significance can be calculated by a normal approximation or, more robustly, by permutation: the values are randomly shuffled among locations many times (say 999), and the observed index is compared with the resulting distribution. Permutation tests make fewer assumptions and are generally preferred.


Spatial Weights: Defining “Near”

Moran’s I depends entirely on how you define neighbors. This is encoded in a spatial weights matrix, which records which features are related and how strongly. The choice isn’t a technicality. It can change your result.

Common definitions

  • Contiguity (queen or rook): polygons that share a border (rook) or a border or a corner (queen) are neighbors. Natural for administrative areas and regular grids.
  • Distance band: all features within a fixed distance are neighbors. Suitable for points.
  • K nearest neighbors: each feature’s closest k neighbors. Guarantees every feature has neighbors, and adapts to varying density.
  • Inverse distance: all features are related, but weights decrease with distance.

Row standardization

In row-standardized weights, each feature’s neighbor weights sum to one, so that the neighbor values are averaged. This prevents features with many neighbors from dominating, and is the usual default for polygons.

Practical guidance

  • Match the definition to the process. If influence travels along borders, use contiguity. If it decays with distance, use distance-based weights.
  • Avoid features with no neighbors (“islands”), which complicate the calculation.
  • Test sensitivity: run the analysis with more than one definition. If your conclusion survives, it is more credible.
  • Use a projected CRS for any distance-based weights. See Coordinate Reference Systems (CRS) Explained Simply.

The Moran Scatterplot

A beautiful way to see what Moran’s I is doing is the Moran scatterplot. It plots each feature’s standardized value on the horizontal axis against the average standardized value of its neighbors (the spatial lag) on the vertical axis. The slope of the line through the points is Moran’s I.

The plot divides into four quadrants:

  • High-High (upper right): a high value surrounded by high values.
  • Low-Low (lower left): a low value surrounded by low values.
  • Low-High (upper left): a low value surrounded by high values.
  • High-Low (lower right): a high value surrounded by low values.

Most points in the first two quadrants suggest positive autocorrelation. Most in the last two suggest negative. The plot lets you see which features drive the result, and spot unusual ones.


Local Moran’s I (LISA)

Global Moran’s I answers whether there is clustering. It doesn’t tell you where. For that you need a local version: Local Indicators of Spatial Association (LISA), introduced by Luc Anselin in 1995. Local Moran’s I computes a value, with a significance test, for each feature, and classifies the significant ones into four types.

  • High-High (HH) cluster: a high value surrounded by high values. A hot spot of the variable.
  • Low-Low (LL) cluster: a low value surrounded by low values. A cold spot.
  • High-Low (HL) outlier: a high value surrounded by low values.
  • Low-High (LH) outlier: a low value surrounded by high values.

The outliers are often the most interesting finding: an affluent household in a poor district, a clinic with unusually poor outcomes in a well-performing region, a contaminated well among clean ones.

Local Moran’s I vs. Getis-Ord Gi*

Both find local clusters, but they answer slightly different questions.

  • Gi* identifies hot and cold spots, concentrations of high or low values, and doesn’t separate outliers.
  • Local Moran’s I identifies clusters and spatial outliers, based on how a feature compares with its neighbors.

Running both is common practice. See Hotspot Analysis with Getis-Ord Gi* Explained.


Running Moran’s I

In ArcGIS Pro

The Spatial Autocorrelation (Global Moran’s I) tool reports the index, z-score and p-value for a chosen field and weighting scheme, and Cluster and Outlier Analysis (Anselin Local Moran’s I) produces the local classification map. The Incremental Spatial Autocorrelation tool tests a series of distances and reports where clustering peaks.

In GeoDa

GeoDa computes global and local Moran’s I, draws the Moran scatterplot, and generates cluster and significance maps interactively. It’s my favorite environment for teaching, and you can explore how different weights change the result.

In QGIS

The core application doesn’t provide a one-click Moran’s I tool, so analysts use GeoDa, Python or R, or look for a plugin that supports the current version. Check the plugin repository, and see Best GIS Plugins for QGIS.

In Python (PySAL)

import geopandas as gpd
from libpysal import weights
from esda.moran import Moran, Moran_Local

# Polygons with a numeric column "rate"
gdf = gpd.read_file("districts.gpkg")

# Queen contiguity weights, row-standardized
w = weights.Queen.from_dataframe(gdf)
w.transform = "R"

# Global Moran's I with a permutation test
mi = Moran(gdf["rate"], w, permutations=999)
print("Moran's I:", round(mi.I, 3))
print("Expected I:", round(mi.EI, 3))
print("z (simulated):", round(mi.z_sim, 2))
print("p (simulated):", mi.p_sim)

# Local Moran's I (LISA)
lisa = Moran_Local(gdf["rate"], w, permutations=999, seed=42)
gdf["lisa_quadrant"] = lisa.q       # 1 = HH, 2 = LH, 3 = LL, 4 = HL
gdf["lisa_p"] = lisa.p_sim
gdf["cluster"] = gdf["lisa_quadrant"].where(gdf["lisa_p"] < 0.05)

Names and options can vary between versions, so check the documentation. For the broader toolkit, see Geospatial Development & Automation: The Ultimate Guide.

In R

The spdep package offers moran.test, moran.mc and localmoran, with a full set of weights tools.


A Worked Example: Is Unemployment Clustered?

Question: does unemployment cluster spatially across the districts of a region, and where?

  1. Prepare the data: a polygon layer of districts with the unemployment rate, in a projected CRS, with valid geometry.
  2. Look at the map and histogram first. What does the distribution look like? Are there extreme values or tiny populations that make rates unstable?
  3. Define neighbors: queen contiguity with row standardization. Note the choice.
  4. Compute global Moran’s I with a permutation test. Suppose it gives I = 0.42, with a p-value of 0.001: significant positive clustering.
  5. Explore the Moran scatterplot to see which districts drive the pattern.
  6. Compute local Moran’s I and map the significant HH and LL clusters, and the HL and LH outliers.
  7. Test sensitivity: repeat with k-nearest neighbors and a distance band. Are the main clusters stable?
  8. Interpret carefully: the clusters suggest regional economic structure, such as an industrial decline area. The statistics say where and how strongly, not why.
  9. Report the index, test, weights, variable and limitations, and map the results clearly.

Related Measures

  • Geary’s C: another global autocorrelation statistic, more sensitive to local differences between neighbors, with an inverse interpretation (values below 1 indicate positive autocorrelation).
  • General G (Getis-Ord): tests whether high values or low values cluster, but unlike Moran’s I, it distinguishes between hot and cold clustering at the global level.
  • Join count statistics: autocorrelation for categorical (binary) data.
  • Correlograms and variograms: show how autocorrelation changes with distance. The variogram is the foundation of kriging.
  • Bivariate Moran’s I: the relationship between one variable and the spatial lag of another.

Using Moran’s I to Check Models

One of the most important uses is diagnostic. After fitting a regression, compute Moran’s I on the residuals.

  • No significant autocorrelation in the residuals: the model captures the spatial structure reasonably.
  • Significant autocorrelation in the residuals: something is missing, such as an important variable or a spatial process. The estimates and tests may be unreliable, and you should consider spatial regression models or additional predictors.

This check is why Moran’s I appears in almost every serious spatial modeling workflow.


Limitations and Pitfalls

  • Dependence on weights. Different neighbor definitions give different values. Always document and test them.
  • The Modifiable Areal Unit Problem. Zoning and aggregation affect results. A pattern at the district level may disappear at the neighborhood level.
  • Scale dependence. Autocorrelation exists at certain scales. A distance that’s too small or too large hides it.
  • Non-stationarity. A single global value assumes the same pattern everywhere. If one region is clustered and another is random, the average can mislead. Local statistics help.
  • Small numbers. Rates based on tiny populations are noisy and create spurious patterns. Consider smoothing or Bayesian adjustments.
  • Edge effects. Features near the boundary have fewer neighbors.
  • Outliers and skewness. A few extreme values can dominate the statistic. Inspect and, if appropriate, transform.
  • Counts vs. rates. Counts tend to track population and make Moran’s I show that people cluster. Use rates or normalized values.
  • Statistical significance isn’t causation. Clustering describes a pattern, not an explanation.
  • Multiple testing in local analysis. With hundreds of features, some will appear significant by chance. Apply corrections where available.
  • Misusing with non-spatial structure. Autocorrelation can be induced by time, by a shared source or by data collection.

Good Practice: A Checklist

  • Define the question and the variable clearly.
  • Use rates or normalized values where appropriate.
  • Work in a projected CRS, with valid geometry. See Top 10 Most Common GIS Errors and How to Fix Them.
  • Choose and justify the spatial weights.
  • Use permutation-based significance when possible.
  • Look at the Moran scatterplot and the local results, not only the global number.
  • Test sensitivity to weights and aggregation.
  • Report the index, z-score, p-value, weights and number of features.
  • Interpret as description, not explanation.
  • Document everything, as recommended in Metadata in GIS: Why It Matters and How to Create It.

Final Thoughts

Spatial autocorrelation is both a nuisance and a gift. It is a nuisance because it breaks the assumptions of familiar statistics, and a gift because it is the pattern we study, the signature of geography itself. Moran’s I gives us a rigorous way to measure it, and its local form shows us where it lives.

Take a variable you know well, such as the income level of districts in your region. Map it, compute Moran’s I, look at the scatterplot and the local clusters. Then change the neighbor definition and see what happens. That experiment teaches more about spatial thinking than any definition.

Where to go next: continue with Spatial Clustering: DBSCAN, K-Means, and Cluster Analysis, and see how autocorrelation connects to the surfaces in Digital Elevation Models (DEM) and Terrain Analysis.

Rachid Khouri

Rachid Khouri

Rachid Khouri is a CAD, BIM and GIS professional, Autodesk Authorized Developer, trainer and technical author with more than 30 years of experience, working with AutoCAD since 1992. He founded GISauthority.com to share practical guidance on GIS and spatial technologies.