--- id: mapbox-earcut version: "2.0.0" license: unclear license_treatment: permissive maintenance: active --- # mapbox-earcut — Python bindings for the mapbox earcut C++ polygon triangulation library License: permissive · Maintenance: active · Downloads: 3.1M/mo ## 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 above — 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 pip install mapbox-earcut uv add mapbox-earcut 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_current - Install friction: medium - Maintenance: active - Downloads: 3.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags polygon triangulation, 2d mesh generation, earcut algorithm, polygon decomposition, computational geometry, mesh triangulation, polygon holes, computational-geometry, mesh-generation, geospatial [View on SkillFed](https://skillfed.io/packages/mapbox-earcut) · [View on PyPI](https://pypi.org/project/mapbox-earcut/)