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.3.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.3.0
File Size Uploaded
coarsen-0.3.0.tar.gz 597.8 kB Details

Built distributions (wheels)

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

Total release size: 6.2 MB

Release files / coarsen-0.3.0.tar.gz

Download URL coarsen-0.3.0.tar.gz
Size 597.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a19088d531cea6797ca68c76f9bfbcedf2766c02005fb8dc73f4e3622f627af0
BLAKE2b-256 checksum
How to use checksums
0221b91e2b3c259e7f951413d569eb9341997bdc5ff6ffc346c6d12e926843fc
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.0-cp310-abi3-win_amd64.whl
Size 340.7 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8bb961879cee0bddb5f2fc50fa0a2b99d3d2812f4f60914597b0e184b7a42176
BLAKE2b-256 checksum
How to use checksums
4622439db70d97ce670a1adaca7067db3dc8351c467a2c74100660d9d3e29b91
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.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
6edc602251a2072ee030345d0ae5caad4e6bafab905e9678f1f0a68ce00f5d91
BLAKE2b-256 checksum
How to use checksums
63fdb998344f8dfbae144193bb182f27fbabaf6860c82a29d0acae8cbc45b092
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.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
3b2d8a83d5c50ef2c947aaf76059ca5bbec60192701cfeb905d9dd01f466f40a
BLAKE2b-256 checksum
How to use checksums
1d987c644eb7411b936a14a92f38253912469e811c883739ecfecd740b2377fd
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.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
5998b620e212380b21ce05577e1db3ddb03dabbf867167c140e98bfabf6f48b1
BLAKE2b-256 checksum
How to use checksums
00a682f8bcfc61c51e1de58fb87e53953bc27f28afba6234f56c693bc3bc81b1
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 465.8 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b5b198e09bf039484c84611e31d5a5b93244a19fd0492983fa082c2c64db8d91
BLAKE2b-256 checksum
How to use checksums
aba6a284b7617108f87e415be391fd8c79e31e824b748df7ce0cb91c99baab9a
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 1, 2026.

Transparency log

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

Download URL coarsen-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 477.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0aeddba9268fe5f0179cda9304938c71305afd448376618cc300f91f5156e54e
BLAKE2b-256 checksum
How to use checksums
ae2de57b4ca294ee4f63b363017139889995f2d40cd98031330d1b0042ae3990
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 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

7 release files

0.2.0

7 release files

0.1.0

7 release files

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