The repository or configuration that created this release differ from a previous release. View details.
contourrs
contourrs converts NumPy rasters into polygons with a Rust core and Python bindings. Use it to trace land-cover classes and segmentation masks, or extract filled contour bands from elevation and probability grids. The Python package requires no GDAL installation.
Documentation · API reference · PyPI · Benchmarks
Install
pip install contourrs
Wheels are available for Python 3.12–3.14 on Linux (x86_64 and ARM64), macOS (Apple Silicon), and Windows (x86_64). NumPy and PyArrow are installed as dependencies.
Polygonize a raster
Each connected region of equal-valued pixels becomes a polygon.
import numpy as np
from contourrs import shapes
labels = np.array([[1, 1, 2], [1, 2, 2], [3, 3, 3]], dtype=np.uint8)
for geometry, value in shapes(labels, connectivity=4):
print(value, geometry["type"])
# 1.0 Polygon
# 2.0 Polygon
# 3.0 Polygon
Use connectivity=8 to join regions that touch diagonally.
Like rasterio.features.shapes, each result pairs a GeoJSON geometry dictionary with its raster value.
shapes() returns a list rather than an iterator.
A 512 × 512 crop of the 2023 USDA Cropland Data Layer for Polk County, Iowa. The right panel shows polygons extracted in tiles and merged across tile boundaries.
Export to Arrow and GeoParquet
The Arrow variants return a pyarrow.Table with a WKB geometry column and a float64 value column.
They avoid constructing a Python geometry dictionary for every polygon and transfer buffers through the Arrow C Data Interface without copying them.
import pyarrow.parquet as pq
from contourrs import shapes_arrow
table = shapes_arrow(labels, connectivity=4)
pq.write_table(table, "polygons.parquet")
The table includes GeoParquet metadata. An affine transform sets output coordinates, but the CRS remains unknown until you assign it; see georeferenced export.
Extract contour bands
contours() interpolates boundaries between raster samples and returns filled polygons between consecutive thresholds.
Each result's value is the lower threshold of its band.
import numpy as np
from contourrs import contours
axis = np.linspace(-2, 2, 128)
x, y = np.meshgrid(axis, axis)
elevation = np.exp(-(x**2 + y**2))
bands = contours(elevation, thresholds=[0.1, 0.3, 0.5, 0.7, 1.0])
This extracts the bands [0.1, 0.3), [0.3, 0.5), [0.5, 0.7), and [0.7, 1.0).
Values outside those intervals are excluded.
Interpolated bands from a synthetic terrain with three peaks. The raster and filled bands share a color scale; white areas fall below the first threshold.
Both operations offer the same two output formats:
| Input | GeoJSON geometry/value pairs | Arrow table |
|---|---|---|
| Categorical raster | shapes() |
shapes_arrow() |
| Continuous raster | contours() |
contours_arrow() |
Masks and map coordinates
All four functions accept mask, nodata, and transform:
from contourrs import shapes_arrow
table = shapes_arrow(
labels,
nodata=0,
transform=(10, 0, 500000, 0, -10, 4500000),
)
Trueentries inmaskinclude samples. Usenodata=0to exclude zeros ornodata=np.nanto exclude NaNs.transformaccepts anaffine.Affineor the six coefficients(a, b, c, d, e, f)used by rasterio.- Inputs and masks must be two-dimensional and C-contiguous. Use
np.ascontiguousarray()after slicing or transposing when needed. - Accepted dtypes are
uint8,uint16,uint32,int16,int32,float32, andfloat64.
Polygonization follows pixel edges; contours interpolate between samples at integer (column, row) coordinates.
See the coordinate conventions when applying a raster transform.
Read raster files with rasterio or another loader, then pass the arrays to contourrs.
Tutorials
- Quickstart covers masks, transforms, and both output formats.
- DEM contours extracts elevation bands from synthetic terrain and a Mount Rainier DEM.
- Tiled CDL polygonization polygonizes land cover in tiles and merges their boundaries.
- TorchGeo field segmentation converts Fields of the World model predictions into field polygons.
Notebook sources are in examples/.
Performance notes describe the benchmark inputs, output costs, and memory measurements.
Development
git clone https://github.com/taylor-geospatial/contourrs.git
cd contourrs
make install
make test
make check
Run make build after changing Rust code.
The checks include Rust formatting and Clippy, Ruff, ty, Pyrefly, and the Rust test suite.
make test also runs the Python tests, including comparisons against rasterio.
See development and docs setup and the Rust architecture for more.
License
Citation
Cite the v0.8.1 Zenodo archive:
@software{isaac_corley_2026_22949666,
author = {Isaac Corley},
title = {isaaccorley/contourrs: v0.8.1},
month = sep,
year = 2026,
publisher = {Zenodo},
version = {v0.8.1},
doi = {10.5281/zenodo.22949666},
url = {https://doi.org/10.5281/zenodo.22949666},
}
Metadata
Release files for contourrs 0.8.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| contourrs-0.8.2.tar.gz | 46.9 kB | With provenance | Details for contourrs-0.8.2.tar.gz |
Built distributions (wheels)
Total release size: 9.4 MB
Release files / contourrs-0.8.2.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2.tar.gz |
|---|---|
| Size | 46.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ce7ffc9defda648d1f20cd326536f9d2a1c4560646cfb0b604af14bc8282a21
|
|
BLAKE2b-256 checksum How to use checksums |
49a4b3bf8dad9f7c2de3974b52ad43e56ee126073db3fbbf530ef0182c8a8030
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp314-cp314-win_amd64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 590.5 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ee2aa44d3c0fcc5c7528c3d202fee6b19477f14f4569aa091159e1c3330433c8
|
|
BLAKE2b-256 checksum How to use checksums |
923adb22226862aad1d16c504e37137abb1e0f3d9b72a67b18190c338da5ca3b
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
302ca15fd4036e83bde7cb0fd7543b186c7b49a2d9962ea6a4ae7caf4244ccd9
|
|
BLAKE2b-256 checksum How to use checksums |
f8f4761de7597368b5f9075b9cd1f5f779a175333f0643a244ae7e5fe48ffe4f
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 793.9 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
0f43d1cf998de0f1e56f1261d2fbb3dc0dc96f7c485226bf7eeaf4a21b5df086
|
|
BLAKE2b-256 checksum How to use checksums |
5db76efeb9d2c7feaeae4e03ef3884d16aaacf9930046d3746db66f08fe10b84
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp314-cp314-macosx_11_0_arm64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 703.7 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
10f68af636982a758acf1f75801b1be7746489632b5e32f4e33dd7b57e2fe536
|
|
BLAKE2b-256 checksum How to use checksums |
ac0afa37cecc56a14d8db8be7e08078430caa3a1b5bddd82e54ae9902e64daa3
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp313-cp313-win_amd64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 590.1 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
408c093b123f75f803957d8740e27912b7c30b3a8ac426d6e9ac62512720a95b
|
|
BLAKE2b-256 checksum How to use checksums |
ac53aa571de4eeea88f280985e46e27f72cbe443d28820c5c8d2fa0d8f93ca1c
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4718fe6adbc3706e5e8679935edead51652e3e99b086b04f72ba00b0ccfc92d8
|
|
BLAKE2b-256 checksum How to use checksums |
ca6c5cbad66eb9b7ac701928a70a1a4728ab58f39dba7017d826dd9ce37c8c18
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 793.7 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
159aedb9f84922a4bdae30f7a2c422eed3565ce5a875fa4c98707f146ad11bdb
|
|
BLAKE2b-256 checksum How to use checksums |
c8516a44bc3ad5bdcc52c857e65e62c2a878b0bab9a562790a45c0f72cb877ef
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp313-cp313-macosx_11_0_arm64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 703.2 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3f93027315b59c100c1360e19589e01f595d51f8cfe9cb772c0772e7feb90a8b
|
|
BLAKE2b-256 checksum How to use checksums |
a1d7d425bb6ed2cecd09932149c7660a85e7ac38421da04cd29527d0462593ab
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp312-cp312-win_amd64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 590.3 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
de606e2a0b97a681297c340aeaf634b132de89140b56cbb91d8ef495468bdb2e
|
|
BLAKE2b-256 checksum How to use checksums |
597fb3ca47aa4ad359abcb863dc79947daeea234fe7bb03a1b83759ec92d38cb
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ed705699a9185040502ca3493ceec0801fce00bc4c7dd38db3240acb411a939
|
|
BLAKE2b-256 checksum How to use checksums |
3f5a187fd0e727cf55c5d429afac839ae3aec61f420eab8aacd3a28a110aa95b
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 793.5 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
934d12f7911838c695252bc52118ff0284d86565411da3cc8501fc9e464af49a
|
|
BLAKE2b-256 checksum How to use checksums |
3444ea26e2f214433d5e70c613713b1944ff29532e06e2df981ccf2c9dd270a7
|
| 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 Oct 5, 2026.
Transparency logRelease files / contourrs-0.8.2-cp312-cp312-macosx_11_0_arm64.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | contourrs-0.8.2-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 703.3 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f1251fe1dd682376142d87a882575f3c65af67fee2de896c79707c4573b3ac29
|
|
BLAKE2b-256 checksum How to use checksums |
bddfdaa1a7f22fb1637b38e9dfdae2e767da8a92caf6712e7e531634f8465794
|
| 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 Oct 5, 2026.
Transparency logSecurity for contourrs 0.8.2
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.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.8.1 github.com/isaaccorley/contourrs
- Added 0.8.2 github.com/taylor-geospatial/contourrs
Attestation for contourrs-0.8.2.tar.gz
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 Oct 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.