Skip to main content

coarsen

coarsen — detailed polygon boundaries reduced to clean edges

CI PyPI Python License: LGPL-2.1-or-later

Parallel geometry simplification for Shapely, powered by Rust. Reduce polygon and line vertices, preserve topology, and keep shared polygon boundaries aligned. Useful for parcel maps, land-cover polygons, and large vector datasets.

Documentation · API · Benchmarks · Contributing · Security

Install

pip install coarsen

Requires Python ≥3.10, NumPy, and Shapely ≥2.1. The Rust core links neither GEOS nor PROJ; the Python interface uses Shapely for geometry conversion. Building from source requires Rust ≥1.85 and maturin.

Simplify shared boundaries

Use coverage_simplify for a polygon coverage: polygons with non-overlapping interiors and exactly matching shared edges. All input polygons are processed together so their simplified boundaries remain aligned.

import coarsen
import shapely

polygons = [
    shapely.Polygon([(0, 0), (5, 0), (5.1, 2), (5, 5), (0, 5)]),
    shapely.Polygon([(5, 0), (10, 0), (10, 5), (5, 5), (5.1, 2)]),
]
result = coarsen.coverage_simplify(polygons, 1.0, threads=8)

# Keep the outer coverage boundary unchanged.
inner_only = coarsen.coverage_simplify(polygons, 1.0, simplify_boundary=False)

Tolerance uses coordinate units. Project longitude/latitude data to a suitable projected CRS before using a tolerance in metres. Invalid coverages are not repaired; check them with shapely.coverage_is_valid when validity is uncertain.

Simplify individual geometries

line = shapely.LineString([(0, 0), (1, 0.1), (2, 0)])
result = coarsen.simplify(line, 0.2)
assert list(result.coords) == [(0.0, 0.0), (2.0, 0.0)]
Function Use for Parallel work
coverage_simplify Matching polygon boundaries Independent groups of shared edges
simplify Individual geometries of any type Independent geometries

simplify preserves each geometry's topology by default. It supports broadcasting, None, and out/where; it does not preserve shared boundaries between separate array elements. preserve_topology=False delegates to Shapely. See the API reference for compatibility details and threading guidance.

Performance and compatibility

The recorded coverage benchmark processes 260,200 polygons across three projected FTW tiles. Eight threads took 6.42–9.65 s per tile, versus 92.03–94.71 s for Shapely, a 9.5–14.5× speedup on that workload. These are historical shared-node measurements, not a guarantee for other hardware or geometry distributions. Methodology, raw samples, and limitations.

The algorithms port GEOS 3.13.1. Tests compare unnormalized WKB bytes against Shapely 2.1.2 at one and eight threads using original GEOS fixtures, seeded random geometries, and real projected parcels. Parity is established for the tested cases; other GEOS versions and untested inputs can differ. Z/M behavior follows the reference algorithm and may drop dimensions. Nonfinite coordinates used in indexes are rejected.

Development

make install
make check
make docs-serve

Requires uv and Rust. make check runs Rust formatting, Clippy, Rust and Python tests, Ruff, ty, and the strict documentation build. Run make build after editing Rust. See CONTRIBUTING.md for release and platform notes.

License and attribution

LGPL-2.1-or-later. Derived from GEOS work by Martin Davis, Paul Ramsey, and other contributors; see NOTICE.

Metadata

Release files for coarsen 0.4.0

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

Source distribution (sdist)

Source distribution for coarsen 0.4.0
File Size Uploaded Provenance Actions
coarsen-0.4.0.tar.gz 604.4 kB With provenance Details for coarsen-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for coarsen 0.4.0
File Actions
coarsen-0.4.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for coarsen-0.4.0-cp310-abi3-win_amd64.whl
coarsen-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for coarsen-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl
coarsen-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for coarsen-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
coarsen-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for coarsen-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
coarsen-0.4.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for coarsen-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
coarsen-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for coarsen-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 6.2 MB

Release files / coarsen-0.4.0.tar.gz

Download URL coarsen-0.4.0.tar.gz
Size 604.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8f0af4cd368d809bf3aa69d23a167b506c847dc5b10e2eaabb7395404c643979
BLAKE2b-256 checksum
How to use checksums
3a1541f1be57cbf44c8203ac6f44e649581c927d7a92ad130de28dfd93a40db7
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-win_amd64.whl

Download URL coarsen-0.4.0-cp310-abi3-win_amd64.whl
Size 336.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2ddb9b166aa2ebb871cf1699b8c8e3c2c401f561b5633c510f48be7c4a281c78
BLAKE2b-256 checksum
How to use checksums
33bbe8df16c91c55450710e6e1ace42bf7d6116edbde67c27e824bafc3bc60db
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL coarsen-0.4.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
7a3f209987fc9c87300344af7898f1243f13b21e88a8d9e74080090994cb1a35
BLAKE2b-256 checksum
How to use checksums
5605cd7c9b1bb2dee74f4651f03a78d4069501425221258e7275dc54644ef6d1
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL coarsen-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6ed111997fedb643361762a49cd21df7957490e6643a56146c737b2b123dd5fe
BLAKE2b-256 checksum
How to use checksums
785a74e8066b817e2d41e3d01eb0b0775d582ff44fc721dd3319fcc727728d9a
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL coarsen-0.4.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
f7d7c24c3746cd376211182fe00e8563109f05ce89fbe800b865cde12c3ae0d7
BLAKE2b-256 checksum
How to use checksums
463cf6a63726f7be9ca6bfda16e8d3f80dc7e30f2fd3f44a25fe005bae7343ea
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL coarsen-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Size 458.1 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ecb752b7d816393cebc0c9e8dbf02300b1ed3d7e2ca8823cd02f4c973cee501c
BLAKE2b-256 checksum
How to use checksums
02c7215056fb821f93433930fefe0fa5e17f75a3cebb869887abd646d8adced8
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 26, 2026.

Transparency log

Release files / coarsen-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL coarsen-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 467.7 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b9253eff777f90bbc1df46fa2919b4d30333f4644bcc3d1751e064205a68246f
BLAKE2b-256 checksum
How to use checksums
9310eb985df46a8841651fdca0693e4ce4baaf7b97e2e68f06cca4af53080e41
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 26, 2026.

Transparency log

Security for coarsen 0.4.0

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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for coarsen-0.4.0.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 26, 2026.

Transparency log

A 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.

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