mapbox-earcut
Python bindings for the mapbox earcut C++ polygon triangulation library
What it is and what it does
mapbox_earcut is a Python wrapper around the C++ Mapbox Earcut library, a fast polygon triangulation engine. It takes a 2D polygon (with optional holes) and returns triangle indices that decompose the polygon into a mesh. The algorithm uses z-order curve hashing to optimize performance and is designed to handle practical geographic and geometric data that may contain holes, twisted edges, or self-intersections—though it does not guarantee mathematically perfect results in all edge cases, only acceptable practical outcomes.
The package exposes four type-specific triangulation functions (float32, float64, int32, int64) to match your vertex data type, and depends only on numpy. It supports Python 3.9 through 3.14 with prebuilt wheels for most common platforms, making installation straightforward despite the compiled C++ backend.
Use it for:
- Triangulate geographic boundaries (country borders, city limits) for rendering or spatial analysis.
- Convert complex 2D shapes with holes into triangle meshes for graphics rendering or physics simulation.
- Decompose architectural floor plans or CAD drawings into triangles for computational geometry operations.
- Prepare polygon data for WebGL or other graphics pipelines that require triangle primitives.
- Batch-process large sets of polygons in geospatial or mapping applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Fast 2D polygon triangulation using the Mapbox Earcut algorithm, with support for holes, twisted polygons, and self-intersections.
Yes. The package is actively maintained, permissively licensed, has no known vulnerabilities, and solves a specific computational geometry problem efficiently. Install it if you need fast, robust polygon triangulation with holes support; skip it if you only work with simple convex polygons or have no triangulation requirement.
Install
mapbox-earcut on PyPI
pip
pip install mapbox-earcutuv
uv add mapbox-earcutpoetry
poetry add mapbox-earcutInstalling mapbox-earcut
Before you install
Medium install friction due to compiled wheels, but well-supported across Python 3.9–3.14 and multiple platforms (macOS, Linux, Windows, ARM). Active maintenance with recent commits.
License in practice
ISC License (permissive) allows commercial and private use with minimal restrictions.
Quickstart
import mapbox_earcut as earcut
import numpy as np
verts = np.array([[0, 0], [1, 0], [1, 1]]).reshape(-1, 2)
rings = np.array([3])
result = earcut.triangulate_float32(verts, rings)
Requires numpy; input vertices must be a 2D array and rings array must specify end-indices for each polygon ring.
Verify before relying
- Whether the library's robustness claims (handling degeneracies and self-intersections) are validated by test coverage or real-world usage reports.
- Performance benchmarks compared to other triangulation libraries for typical polygon sizes.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 271 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,071,615/month — #2,767 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mapbox_earcut-2.0.0-cp310-cp310-macosx_10_13_x86_64.whl; mapbox_earcut-2.0.0-cp310-cp310-macosx_11_0_arm64.whl; mapbox_earcut-2.0.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mapbox_earcut-2.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mapbox_earcut-2.0.0-cp310-cp310-musllinux_1_2_aarch64.whl; mapbox_earcut-2.0.0-cp310-cp310-musllinux_1_2_x86_64.whl; mapbox_earcut-2.0.0-cp310-cp310-win32.whl; mapbox_earcut-2.0.0-cp310-cp310-win_amd64.whl; mapbox_earcut-2.0.0-cp311-cp311-macosx_10_13_x86_64.whl; mapbox_earcut-2.0.0-cp311-cp311-macosx_11_0_arm64.whl; mapbox_earcut-2.0.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mapbox_earcut-2.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mapbox_earcut-2.0.0-cp311-cp311-musllinux_1_2_aarch64.whl; mapbox_earcut-2.0.0-cp311-cp311-musllinux_1_2_x86_64.whl; mapbox_earcut-2.0.0-cp311-cp311-win32.whl; mapbox_earcut-2.0.0-cp311-cp311-win_amd64.whl; mapbox_earcut-2.0.0-cp311-cp311-win_arm64.whl; mapbox_earcut-2.0.0-cp312-cp312-macosx_10_13_x86_64.whl; mapbox_earcut-2.0.0-cp312-cp312-macosx_11_0_arm64.whl; mapbox_earcut-2.0.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
bermudaProvides Rust-accelerated triangulation…
permissive · top 15,000 on PyPI
triangleTriangle wraps Jonathan Richard Shewchuk's C…
copyleft · top 15,000 on PyPI
pyclipperPyclipper performs polygon clipping operations…
permissive · top 5,000 on PyPI
cytriangleCyTriangle wraps Jonathan Shewchuk's Triangle…
copyleft · top 15,000 on PyPI
shapely-polyskelComputes the straight skeleton of a polygon, a…
copyleft · top 15,000 on PyPI
quadrilateral-fitterFits the smallest-area quadrilateral that…
permissive · top 15,000 on PyPI
gdstkGdstk is a Python module for creating and…
unclear · top 15,000 on PyPI
vhacdxComputes approximate convex decomposition of…
unclear · top 5,000 on PyPI
pygeoifPyGeoIf provides lightweight, pure-Python…
copyleft · top 15,000 on PyPI