Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pygeostats

CI License: MIT

Geostatistics for Python with a Rust-accelerated core: variograms, kriging, point-pattern analysis and spatial autocorrelation.

Status

Alpha. 0.1.0a1 is published to PyPI as a pre-release, and the package is not ready for production use.

The package builds and imports, and the test suite runs green. Wheels are published for Linux and macOS on x86_64 and arm64, and for Windows on x86_64. Known defects and unfinished features are listed under Known limitations; read that section before relying on directional or anisotropy analysis.

This project was previously called pyspatialstats, and was renamed because that name belongs to an existing, actively maintained package on PyPI by Jasper Roebroek. The two are unrelated.

Features

  • Variograms — empirical estimation, theoretical models (exponential, spherical, gaussian, Matérn), directional variograms and anisotropy detection
  • Kriging — ordinary, simple and universal, with prediction variance
  • Large data — streaming variogram accumulators, memory-mapped input and sparse bin summaries; kriging with approximate neighbours, spatial tiling, checkpointing and resume via predict_parallel()
  • Point patterns — nearest-neighbour distances, Ripley's K and L, G and F functions, pair correlation, DBSCAN, kernel density, Poisson and Cox process simulation, spatial segregation indices
  • Spatial autocorrelation — Moran's I and Geary's C (global and local), Getis-Ord G and Gi*, and weight-matrix builders (kNN, distance band, inverse distance)
  • Validation — leave-one-out and spatial k-fold cross-validation, AIC/BIC model selection, residual diagnostics
  • Rust core — the distance, variogram and kriging kernels are compiled extensions built with PyO3 and maturin
  • Familiar API — estimators expose .fit(), .predict() and .score(), and coordinate arguments accept NumPy arrays or GeoPandas GeoDataFrames

Installation

pip install pygeostats

Requires Python 3.11 or newer. Wheels are built against the stable ABI (cp311-abi3), so one wheel per platform covers every supported Python version. On platforms without a wheel, pip builds from the source distribution, which needs a Rust toolchain.

0.1.0a1 is a pre-release. pip installs it while no stable release exists; once one does, pip install --pre pygeostats is needed to get pre-releases.

To build from source, a Rust toolchain is required, since the core extension is compiled:

git clone https://github.com/DiogoRibeiro7/pygeostats.git
cd pygeostats
pip install .

For development, including the test dependencies:

pip install -e ".[dev,test]"

Quick start

import numpy as np
from pygeostats.variogram import EmpiricalVariogram, Variogram
from pygeostats.kriging import OrdinaryKriging

rng = np.random.default_rng(0)
coords = rng.uniform(0, 10, size=(100, 2))
values = rng.standard_normal(100)

# Empirical variogram
ev = EmpiricalVariogram(coords, values)
ev.compute()

# Fit a theoretical model
model = Variogram(model="exponential")
model.fit(ev.distances_, ev.gamma_)

# Interpolate
kriging = OrdinaryKriging(model)
kriging.fit(coords, values)
predictions = kriging.predict(coords)

Point patterns and spatial autocorrelation are used directly:

from pygeostats import ripley_k_function, morans_i, spatial_weights_knn

radii = np.linspace(0.01, 0.25, 25)
k = ripley_k_function(coords, radii, area=100.0)

weights = spatial_weights_knn(coords, k=8)
result = morans_i(values, weights)

Known limitations

  • The workflow from directional variograms to anisotropic kriging is not implemented. DirectionalVariogram.estimate_initial_parameters() and create_anisotropic_variogram_from_directional() raise NotImplementedError, and both are covered by strict xfail tests. InitializationEnsemble and RangeInitializer from pygeostats.variogram.initialization provide starting values in the meantime.
  • detect_anisotropy() estimates the anisotropy axis, but its ratio runs low: about 1.4 for a 2.9:1 field, against about 1.06 for an isotropic one. Treat it as a detection statistic rather than an estimate of the true ratio. At the default ratio_threshold of 1.2, some isotropic fields are flagged as anisotropic.
  • RangeInitializer returns starting values for a fit, not estimates of a model's range parameter.
  • InitializationEnsemble blends the principal axis of the sampling locations into its angle, which can pull it off the field's axis: in one test it reported 74 degrees for an axis at 60.

The point-pattern, spatial-autocorrelation and clustering modules are not affected by any of the above and pass their tests.

Variogram fitting reports when it cannot be trusted. If the empirical variogram does not constrain the chosen model — typically because it is still rising at the largest observed lag — Variogram.fit sets converged_ to False and adds a warning, rather than returning a range as though it were reliable.

Type annotations are incomplete: mypy reports findings in first-party code and runs as an advisory CI step rather than a gate.

Development

pip install -e ".[dev,test]"

pytest tests/                  # 183 passed, 2 xfailed
black --check src/python/ tests/
ruff check src/python/ tests/
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings

# note the flags: extension-module tells the linker not to link libpython,
# which is correct for the cdylib but breaks a plain `cargo test` on Linux
# and macOS with undefined Python symbols
cargo test --no-default-features --features parallel

The Rust toolchain is pinned in rust-toolchain.toml, so rustup will fetch the matching compiler automatically.

See CHANGELOG.md for release notes, CONTRIBUTING.md for the full workflow and ROADMAP.md for planned work.

License

MIT. See LICENSE.

Release files for pygeostats 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygeostats 0.1.0a1
File Size Uploaded
pygeostats-0.1.0a1.tar.gz 172.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pygeostats 0.1.0a1
File
pygeostats-0.1.0a1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details
pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details
pygeostats-0.1.0a1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pygeostats-0.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size:2.4 MB

Release files / pygeostats-0.1.0a1.tar.gz

Download URL pygeostats-0.1.0a1.tar.gz
Size 172.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1ea017132b78e1080e06ffa7056d8bbface91b4f10f7e5b555459968b0e030e0
BLAKE2b-256 checksum
How to use checksums
b64e231e5a92be4b3c52ae63f79fbfe3a8248919089782b0480c3430a24378a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / pygeostats-0.1.0a1-cp311-abi3-win_amd64.whl

Download URL pygeostats-0.1.0a1-cp311-abi3-win_amd64.whl
Size 402.3 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f6182f79b6382166bef8608b5053e1ac8922035218f93cf19f11bbe2392a327b
BLAKE2b-256 checksum
How to use checksums
6dd9c2aeeac25ed872ad4e6ce7ad4ad731d6c48a777c8de4793687a89d2215de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 477.7 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
75e72804e49fda92904dbe9aa9e22186d54c4d2cef1e550e88d5df44a0e375f5
BLAKE2b-256 checksum
How to use checksums
26012637fdd2abda4dd34ad9926d076af649efd916cbac264cccc9c32bb02230
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pygeostats-0.1.0a1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 453.6 kB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
2bb17be88bfca15f7bf7d33158d42abacc916f79eb368efe81dd38a7e37b3bee
BLAKE2b-256 checksum
How to use checksums
091dde88c1be616562bfeea6f10b96717ad0782eee9f7e90e072452b8448e540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / pygeostats-0.1.0a1-cp311-abi3-macosx_11_0_arm64.whl

Download URL pygeostats-0.1.0a1-cp311-abi3-macosx_11_0_arm64.whl
Size 433.5 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2e52652edb5695709224be728a71cefba76df50db33ec0c9618b4b710039f32d
BLAKE2b-256 checksum
How to use checksums
13868b226cde7f0ddcec60358984a82c5e49e57437f21450ede959be3667c263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / pygeostats-0.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pygeostats-0.1.0a1-cp311-abi3-macosx_10_12_x86_64.whl
Size 445.9 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
62c658f4e88a2ea0c4130d79e5b2fd732da9b7fdb5d6540d541961e9aa4d639b
BLAKE2b-256 checksum
How to use checksums
7cd2fd83d3a843687806a175e89dc99c3e9fc4c76ff7ed671284f08cef5a028c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page