Add spatial autocorrelation statistics (Moran's I, LISA, Geary's C)

Open
#1,135 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
numpy, python
Domain
data

Research direction

Start by reading hotspots() and emerging_hotspots(), then trace the existing ArrayTypeFunctionMapping backend dispatch pattern for numpy, cupy, and dask variants. Define how global and local statistics, permutation p-values, spatial weights, and categorical join counts fit the raster API; done means the listed statistics support the specified backends and return scalars or grid-matched DataArrays as described.

Written by the indexing model from the issue text.

Description

after-1.0.0-release enhancement

Motivation

We already have Getis-Ord Gi* via hotspots() and emerging_hotspots(), but Moran's I (global and local/LISA) is the other fundamental spatial statistic that most analysis workflows depend on. Right now users have to leave xarray-spatial to compute these, which breaks the pipeline.

Scope

Statistics:

  • Global Moran's I
  • Local Moran's I (LISA) with significance testing via random permutation
  • Geary's C (global and local)
  • Join count statistics for categorical rasters

Spatial weights:

  • Queen and rook contiguity derived from the raster grid structure
  • Distance-band weights (binary and inverse-distance)

Implementation notes

  • Should follow the existing backend dispatch pattern: numpy, cupy, dask+numpy, dask+cupy via ArrayTypeFunctionMapping.
  • Local statistics (LISA, local Geary) return xarray DataArrays matching the input grid. Global statistics (Moran's I, Geary's C) return scalar results.
  • P-values from permutation testing should be included in the output, either as a second DataArray or as attributes.
  • Permutation-based significance is embarrassingly parallel and maps well to both dask chunks and GPU threads.

Related

  • hotspots() already computes Gi* z-scores
  • emerging_hotspots() does temporal hot spot classification
  • PySAL/esda covers this for vector data, but there's nothing raster-native
Dominant language
Python
Stars
972
Forks
92
Avg merge
2d 12h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xarray-contrib/xarray-spatial

All issues in xarray-contrib/xarray-spatial

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.