Turf.jsTransformation

turf.tesselate

What is turf.tesselate?

turf.tesselate triangulates a Polygon (including polygons with holes) using the earcut algorithm and returns a FeatureCollection<Polygon> where each feature is a triangle. Triangulation is the first step for many WebGL rendering pipelines and area-sampling workflows.

JavaScript
turf.tesselate(polygon) → FeatureCollection<Polygon>

When would you use turf.tesselate?

Use turf.tesselate when you need triangles for custom WebGL rendering, heatmap sampling, or physics/collision-style calculations. It is also useful for decomposing complex polygons into simple pieces for iteration — for example, to pick a random point inside a polygon, tesselate and weight by triangle area.

In a Node.js pipeline, tesselation can be a preprocessing step for printing, 3D extrusion meshes, or feeding triangulated geometry into a GPU-based visualiser.

Code
undefined

FAQs

Does it handle polygons with holes?

Yes — earcut handles interior rings correctly, producing triangles that fill the donut region.

How do I install just tesselate?

npm install @turf/tesselate. It depends on @turf/helpers and earcut.

Can I triangulate a FeatureCollection?

Not directly — iterate the collection and call tesselate per polygon, then merge the outputs. Each input is treated independently.

What about MultiPolygon?

Use turf.flatten first to split a MultiPolygon into individual Polygon features, then tesselate each.