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.0.tar.gz (553.7 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.0-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.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: oxidized_rasterstats-0.1.0.tar.gz
  • Upload date:
  • Size: 553.7 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.0.tar.gz
Algorithm Hash digest
SHA256 e1e91b5528d16f73c9ea03e0ed8bd0d9b311d2fe191e4f03ee9ff26a40dc0f5b
MD5 bf010cb694a23449f70382b252b77a0a
BLAKE2b-256 fabfcf97c09de57111d361fb857bef6630bc63948344a54df3b487d6fd4a4bf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.0.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.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5d42f5f3cb834da683a91bd156049872925ddd4d4732876200b36d41ff197a08
MD5 13355aa77dad3a111495db2b83d0816a
BLAKE2b-256 cdeebc6188c67a7d153c312c83d58b210d47b50e34caaf00c2fdb6c44c3bced5

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.0-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.0-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 37650caa9db4d63fd23b6c19f4a2417e2f6abb7830986156598fbb31ab75f2e9
MD5 ea8698123c5cd9ac613770d08aa77651
BLAKE2b-256 61fd6016f48c267452d4afa5ad31fc57eda74bdf07f864a9bf072023610a4c76

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.0-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.0-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 79ba836509dd7df934453dc2c069761c441a710e550203888ec1c92bffcce103
MD5 31fc04d5c82e404d28dc6f88c0c9fb4a
BLAKE2b-256 d9aab25fc59bbbd350cee016eeb55bf7aad129deed43b57f47555b5a5ca66a30

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.0-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.0-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for oxidized_rasterstats-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 cdc2e7b7ebbb3df55fc3db2a7e491a2716eedf514c870d5ca3939ecc0ec7128d
MD5 b27297cc315267596adf2340d1fe0460
BLAKE2b-256 a62ccd97173b0d10631c050eb8e2dad7c85bb08e828aa161e275d9fc20d01028

See more details on using hashes here.

Provenance

The following attestation bundles were made for oxidized_rasterstats-0.1.0-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