Skip to content

serapeum-org/geostatista

Repository files navigation

Documentation Python Versions License: GPL v3 pre-commit PyPI version codecov

Current release info

Name Downloads Version Platforms
Conda Recipe Conda Downloads Downloads PyPI - Downloads Conda Version PyPI version Conda Platforms

geostatista

geostatista is the geostatistics tier of the serapeum stack: variograms, kriging, and spatial autocorrelation, built on top of pyramids and its GDAL stack. Input is scattered point observations; output is a continuous surface plus an uncertainty estimate, or per-feature autocorrelation statistics.

Main Features

  • Variograms — empirical variogram clouds (Matheron / Cressie estimators) and fitted theoretical models (spherical, exponential, gaussian, matern, plus power / nugget functions).
  • Ordinary kriging — from a fitted variogram onto a regular grid, returning a 2-band KrigedSurface (band 0 = estimate, band 1 = kriging variance) with a cKDTree moving neighborhood for large sample sets.
  • Validation — leave-one-out cross-validation with ME / RMSE / standardized-error diagnostics.
  • Spatial autocorrelation — a sparse Weights matrix (queen / rook contiguity, k-nearest, distance-band) feeding global (Moran's I, Geary's C) and local (Local Moran / LISA, Getis-Ord Gi*) statistics, with one-call spatial_autocorrelation / hotspots facades.
  • Plotting — variogram, LISA-cluster, and hotspot maps through cleopatra (the viz extra).

Everything hangs off Samples, a FeatureCollection subclass, so a column name is always a method argument. See ADR 0001 for the pyramids ↔ geostatista boundary (pyramids keeps IDW and the free gdal.Grid algorithms; geostatista owns every variogram and kriging variant).

Installation

conda (conda-forge)

conda install -c conda-forge geostatista

List the versions available on your platform with:

conda search geostatista --channel conda-forge

pip (PyPI)

pip install geostatista

From GitHub (latest development)

pip install git+https://github.com/serapeum-org/geostatista

Quick start

Krige scattered point observations onto a grid, with an uncertainty band:

from geostatista import Samples

samples = Samples.read_file("rain_gauges.geojson")   # a Samples is-a FeatureCollection

vg = samples.variogram("rain").fit(model="spherical")   # explore + fit spatial structure
surface = samples.krige("rain", vg, cell_size=1000)      # 2-band KrigedSurface (estimate + variance)
surface.to_file("rain.tif")                              # self-describing GeoTIFF (GS_* tags)

cv = samples.cross_validate("rain", vg)                  # leave-one-out diagnostics
print(cv.attrs["summary"])                               # ME, RMSE, standardized error, correlation

Measure and map spatial autocorrelation over polygon features:

from geostatista import Weights, morans_i, local_morans

w = Weights.queen(tracts)                 # queen-contiguity weights
morans_i(tracts, "income", w)             # global Moran's I (I, EI, z, p)
lisa = local_morans(tracts, "income", w)  # per-feature LISA clusters (HH / LL / HL / LH / ns)

See the documentation for the full guide.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages