ST_TriangulatePolygon
What is ST_TriangulatePolygon?
ST_TriangulatePolygon is a PostGIS function that computes a constrained Delaunay triangulation of a polygon. Unlike ST_DelaunayTriangles, which triangulates the convex hull of input points, this function respects polygon boundaries and holes — the resulting triangles exactly tile the polygon's interior.
ST_TriangulatePolygon(geometry geom) → geometryThe result is a GeometryCollection of triangle polygons covering the input.
When would you use ST_TriangulatePolygon?
Use ST_TriangulatePolygon to decompose irregular polygons into triangles for 3D rendering, finite-element analysis, area-weighted interpolation, or for generating a mesh that respects polygon boundaries and holes. It is the tool of choice when the triangulation must honour input edges.
1SELECT id, ST_TriangulatePolygon(geom) AS mesh
2FROM parcels;FAQs
How is this different from ST_DelaunayTriangles?
ST_DelaunayTriangles works on arbitrary vertices and produces triangles covering the convex hull — it ignores polygon boundaries. ST_TriangulatePolygon is constrained: it accepts only a polygon and produces triangles that exactly fill the polygon, respecting edges and holes.
Does it handle polygons with holes?
Yes. Holes are excluded from the triangulation — the output covers only the polygon's interior (outer ring minus inner rings). This makes it safe for features like donuts or polygons with internal clearings.
What geometry type does it return?
A GeometryCollection containing the individual triangle polygons. To iterate over them use ST_Dump, or extract them all with ST_CollectionExtract(result, 3).
Is the triangulation unique?
For a given polygon, the constrained Delaunay triangulation is unique up to ties when four or more points are cocircular. PostGIS picks a consistent tiebreaker, so the output is deterministic for a given input.