Add spatial autocorrelation statistics (Moran's I, LISA, Geary's C)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
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
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-scoresemerging_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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xarray-contrib/xarray-spatial
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
xarray-contrib/xarray-spatial#3726 ·
-
api area:surface bug severity:medium sweep-api-consistency
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
xarray-contrib/xarray-spatial#3712 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
xarray-contrib/xarray-spatial#3710 ·
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
xarray-contrib/xarray-spatial#3707 ·
-
area:surface documentation user-guide-example
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
xarray-contrib/xarray-spatial#3464 ·
All issues in xarray-contrib/xarray-spatial
Similar issues
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100