Skip to content

PolyShell

A high-performance coverage-preserving polygon reduction library for Python, written in Rust.

Benchmark Benchmark

Time to reduce a 50,000 point polygon by 90%.


Highlights

  • ✅ Guarantees encapsulation of the initial polygon.
  • 🔥 Rust-powered performance.
  • 🧩 A simple Python API to access all reduction methods and modes.
  • 🌍 Seamlessly integration with NumPy and Shapely.
  • 📏 Tunable accuracy and reduction rates.
  • 🐍 Python and PyPy compatible.

PolyShell is supported by the ECMWF through the Code for Earth programme.


Installation

PolyShell is available on PyPI for easy installation:

pip install polyshellSuccessfully installed polyshell

PolyShell can also be built from source using maturin. See the guide here.


Example

All of PolyShell's reduction algorithms are accessible through reduce_polygon.

from polyshell import reduce_polygon

original = [
    (0.0, 0.0),
    (0.0, 1.0),
    (0.5, 0.5),
    (1.0, 1.0),
    (1.0, 0.0),
    (0.0, 0.0),
]

reduced = reduce_polygon(original, "auto", method="vw")

For all the available options, see the full list of features.


Learn more

For more information see the guide