skillfed

mapbox-earcut

Python bindings for the mapbox earcut C++ polygon triangulation library

mapbox-earcut v2.0.0 3.1M downloads/30d#2,767 on PyPI40
Permissive license Active released

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-earcut

uv

uv add mapbox-earcut

poetry

poetry add mapbox-earcut

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: ISC License (ISCL)Programming Language :: C++Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Free Threading :: 1 - Unstable

Tags

polygon triangulation2d mesh generationearcut algorithmpolygon decompositioncomputational geometrymesh triangulationpolygon holes
computational-geometrymesh-generationgeospatial

More Mathematics packages