Skip to main content

Rust-accelerated drop-in replacement for python-rasterstats

Project description

oxidized-rasterstats

Rust-accelerated, GDAL-backed implementation of rasterstats with drop-in Python API compatibility.

Status

  • Import path compatibility: from rasterstats import zonal_stats, point_query
  • Build/packaging flow: maturin
  • Rust fast paths: zonal stats + point query
  • Python fallback: upstream-compatible behavior preserved
  • Non-overlap nodata semantics: matches upstream python-rasterstats boundless footprint behavior
  • Rust dispatch exceptions are logged before fallback so backend failures are visible in operations logs

Quick Start

python -m venv .venv
. .venv/bin/activate
pip install -U pip
pip install -e ".[test,perf]"
pip install maturin

python scripts/sync_upstream.py \
  --repo /workdir/python-rasterstats \
  --sha e51b48a62e3ac7e4ef4a81a8c2a8e5b90fa5e8ac

maturin develop --release

Dispatch Model

  • Default mode enables Rust fast-path for eligible zonal_stats and point_query calls.
  • Set OXRS_DISABLE_RUST=1 to force Python fallback behavior.
  • Fast path auto-falls back to Python for unsupported dynamic cases.

Examples:

# Default mode (zonal fast path active when eligible)
PYTHONPATH=python python -c "from rasterstats import zonal_stats; print(callable(zonal_stats))"

# Force Python fallback for both APIs
PYTHONPATH=python OXRS_DISABLE_RUST=1 python -c "from rasterstats import point_query; print(point_query('POINT(245309 1000064)','tests/upstream/data/slope.tif')[0])"

# Explicit Rust-on flag is optional (kept for compatibility)
PYTHONPATH=python OXRS_ENABLE_RUST=1 python -c "from rasterstats import zonal_stats; print(zonal_stats('tests/upstream/data/polygons.shp','tests/upstream/data/slope.tif')[0])"

Build and Test Commands

# Parity + API compatibility
PYTHONPATH=python pytest tests/upstream tests/compat -q

# Rust unit tests
cargo test --all

# Regression denylist
PYTHONPATH=python pytest tests/regression -q

# Forced Python fallback sweep
PYTHONPATH=python OXRS_DISABLE_RUST=1 pytest tests/upstream tests/compat -q

# Performance suites
PYTHONPATH=python pytest tests/perf -q -m perf_small --benchmark-only --benchmark-min-rounds=5
PYTHONPATH=python pytest tests/perf -q -m perf_large --benchmark-only --benchmark-min-rounds=5

PyPI Release Workflow

  • Tag a release commit with v* (for example v0.1.0) and push the tag.
  • GitHub workflow .github/workflows/release-wheels.yml builds:
    • Linux wheels for CPython 3.9-3.12
    • source distribution (sdist)
  • Publish job uses PyPI Trusted Publishing with environment: pypi.

Benchmark Snapshot (2026-02-16)

See benchmarks/results/2026-02-16.md.

  • Small fixture (vacant-better):
    • Zonal: Rust 290.9ms, baseline 2264.8ms (7.78x)
    • Point query: Rust 144.2ms, baseline 1829.9ms (12.69x)
  • Large fixture (copacetic-note local):
    • Zonal: Rust 2.655s, baseline 27.969s (10.53x)
    • Point query: Rust 1.242s, baseline 21.613s (17.41x)

Upstream Attribution

oxidized-rasterstats is built from and compatible with the upstream python-rasterstats project by Matthew Perry and contributors.

  • Upstream project: python-rasterstats (author: Matthew Perry / perrygeo)
  • Pinned upstream snapshot: vendor/upstream_rasterstats/SHA.txt
  • Vendored upstream source/tests: vendor/upstream_rasterstats/
  • Imported parity fixtures/tests: tests/upstream/
  • Python compatibility copies based on upstream modules: python/rasterstats/_upstream_main.py, python/rasterstats/_upstream_point.py, python/rasterstats/io.py, python/rasterstats/utils.py, python/rasterstats/cli.py

See docs/attribution.md for attribution and licensing details.

License

  • Project license: BSD 3-Clause (LICENSE)
  • Copyright and component-level ownership notes: NOTICE.md
  • Upstream python-rasterstats license snapshot: vendor/upstream_rasterstats/LICENSE.txt

Repository Layout

  • python/rasterstats/: compatibility package + dispatcher + upstream fallback copies
  • src/: Rust core (zonal, point, raster, stats, errors, geom)
  • tests/upstream/: imported upstream tests
  • tests/regression/: issue denylist coverage
  • tests/perf/: benchmark harness
  • scripts/: upstream sync, fixture generation, API manifest tooling
  • docs/upstream_issues/: issue snapshots
  • vendor/upstream_rasterstats/: pinned upstream source/tests

Review Guide

Start with docs/review_guide.md for scope, command log, and file-level review map.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oxidized_rasterstats-0.1.1.tar.gz (553.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

oxidized_rasterstats-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl (57.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

oxidized_rasterstats-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl (57.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

oxidized_rasterstats-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl (57.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

oxidized_rasterstats-0.1.1-cp39-cp39-manylinux_2_39_x86_64.whl (57.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

File details

Details for the file oxidized_rasterstats-0.1.1.tar.gz.

File metadata

  • Download URL: oxidized_rasterstats-0.1.1.tar.gz
  • Upload date:
  • Size: 553.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for oxidized_rasterstats-0.1.1.tar.gz
Algorithm Hash digest
SHA256 febe045eb1634ec058f04e9620fad5fe45beecd1d79e230153ff3e456b147fe2
MD5 d99ada6a6a6d507af9710e75bbcf3170
BLAKE2b-256 a705aad350ce4309b64b0d44dc46035fc2b2a6f6c1657d2aedad6f8acedb6e39

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.1.tar.gz:

Publisher: release-wheels.yml on rogerlew/oxidized-rasterstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxidized_rasterstats-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 fbdf359c735d56dc6bcc1cae6477866030315c109dbf0152d196e0ff682fe2f1
MD5 25888bccf1c85cbbb500153431576a73
BLAKE2b-256 b920cee785a42b9382eb697fc0cee7336a9d43a050ec56ddd54adc1874ce0f6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl:

Publisher: release-wheels.yml on rogerlew/oxidized-rasterstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxidized_rasterstats-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 6feebfb438e4891b8f0ce9d7a5ad317a3f391b7a52cacaf77c42eddb092dfea2
MD5 dad5d0630c33962186d0134486455cc9
BLAKE2b-256 c2d1a648a3d79d564f0e8ab0dcdbb4cff90e87955b6310213b7323b6b3ba66d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.1-cp311-cp311-manylinux_2_39_x86_64.whl:

Publisher: release-wheels.yml on rogerlew/oxidized-rasterstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxidized_rasterstats-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 4db47b604f5ef3e8310c22b1ab6ac6ad879f39799fd6bea8791f9b019821d85e
MD5 fee395e672d5314fbffbb1a5600a5eca
BLAKE2b-256 39fd6c98d3c12acf771591cccd217b928549d7f2060d6051bd6170b1add66cc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.1-cp310-cp310-manylinux_2_39_x86_64.whl:

Publisher: release-wheels.yml on rogerlew/oxidized-rasterstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oxidized_rasterstats-0.1.1-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.1-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 afb7b8aaab0357dbb6d13f35c21d7d48f2b0fa6e7698f6e2c8d277fcbe08fa60
MD5 31ca564d7b077514c9baf8fd6916f489
BLAKE2b-256 06f82474dd2a4ca880d03bc2c59c24e785417d600d502d18f6ef3706e7a19d62

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.1-cp39-cp39-manylinux_2_39_x86_64.whl:

Publisher: release-wheels.yml on rogerlew/oxidized-rasterstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page