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.5.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.5.0
File Size Uploaded Provenance Actions
coarsen-0.5.0.tar.gz 607.6 kB With provenance Details for coarsen-0.5.0.tar.gz

Built distributions (wheels)

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

Total release size: 6.2 MB

Release files / coarsen-0.5.0.tar.gz

Download URL coarsen-0.5.0.tar.gz
Size 607.6 kB
Tags Source
SHA-256 checksum
How to use checksums
50fa6ec42940a1988fc0b8d8454ffedb8b011f2ef127839f877511699c28c24f
BLAKE2b-256 checksum
How to use checksums
ca0cfd5deed026287c3beb1bc18c56fb2d0337335d955842e2ebb72c2b72ba70
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.0-cp310-abi3-win_amd64.whl
Size 346.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
26795c3210c271caee63d75724f577ca2b45bab86d93cba639645216aaee3ad2
BLAKE2b-256 checksum
How to use checksums
a12c2c5188cdafbcc6a54d4da181ee81801b8da8ff28789f7733581d5b3e9d15
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.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
a8357ad3afe4fbc4b61ff0c7e436be233ba0842f645091acdc122a7ccc188206
BLAKE2b-256 checksum
How to use checksums
0fba6cfc9f6defa1062f4e76b7b7ecdea177dda9c26230a3fab9fc69b39e7159
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_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
45f151ca92dd4d9712c1677629afcf6342f14445f4ee3fe313cd5a604f96d704
BLAKE2b-256 checksum
How to use checksums
e993a2c5ae93bab6d4c5e9d509a2020205ca6c86261479cc259225b475b72952
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
6a114139ded4e3d9cedd2ebedb5dd94c5762a2087ef1656fadb656d148b31f15
BLAKE2b-256 checksum
How to use checksums
1e2a817304e4130d7aac20c534461de2585796dd1063cf763ba7ffd6ea846f86
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Size 470.0 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2cb88e9b08db9ab7a590b19e88e3ff917dbb83a8cc6e33652ff03e456ebff947
BLAKE2b-256 checksum
How to use checksums
fc44807a645132aa69faee5bccecd9bccc78d777f3b054312972a217e5ef8e3d
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 Nov 13, 2026.

Transparency log

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

Download URL coarsen-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 479.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
197656b1fe6dce13babed802823c57cca3dd90820fbb891de47870533d7ee4c5
BLAKE2b-256 checksum
How to use checksums
f5efe6a75f027f6c4a71aedb4f1ec7d2e4bb5708b65e0ed8c66514e1db5c6e8b
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 Nov 13, 2026.

Transparency log

Security for coarsen 0.5.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.5.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 Nov 13, 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