ST_DelaunayTriangles
What is ST_DelaunayTriangles?
ST_DelaunayTriangles is a PostGIS function that computes a Delaunay triangulation from the vertices of the input geometry. The result is a set of triangles whose circumcircles contain no other input vertex — a property that makes Delaunay triangulations the natural basis for interpolation, mesh generation, and spatial adjacency.
ST_DelaunayTriangles(geometry g1, float tolerance = 0.0, int4 flags = 0) → geometryflags = 0 returns a GeometryCollection of triangle polygons; flags = 1 returns a MultiLineString of edges; flags = 2 returns a TIN. tolerance snaps nearby vertices together before triangulating.
When would you use ST_DelaunayTriangles?
Use ST_DelaunayTriangles to build a triangular mesh over a point set for terrain modelling, interpolation (TIN-based DEMs), or for deriving neighbourhood relationships between scattered observations. It is also the engine behind ST_VoronoiPolygons and ST_ConcaveHull, so understanding it helps reason about those algorithms.
1SELECT ST_DelaunayTriangles(ST_Collect(geom), 0.01, 0) AS mesh
2FROM elevation_points
3WHERE tile_id = 'A12';FAQs
What does the tolerance parameter do?
tolerance snaps vertices within that distance to each other before triangulating, which is important for noisy input — without snapping, nearly-coincident points produce sliver triangles. Set it to roughly the positional accuracy of your data (e.g. 0.01 metres for survey-grade points, 1.0 for rough GPS).
What output does flags control?
flags = 0 (default) gives a GeometryCollection of triangle polygons — the most useful format for rendering or further processing. flags = 1 gives a MultiLineString of triangulation edges. flags = 2 returns a TIN geometry.
Why is the triangulation restricted to the convex hull?
Delaunay triangulations are defined over the convex hull of the input point set — there are no triangles outside it. If you need a constrained triangulation that respects polygon boundaries, use ST_TriangulatePolygon instead.
How does this compare to ST_VoronoiPolygons?
The Voronoi diagram is the dual of the Delaunay triangulation — each triangle vertex corresponds to a Voronoi cell, and each Delaunay edge is perpendicular to a Voronoi edge. Use Delaunay when you want triangles (for interpolation, meshing); use Voronoi when you want proximity regions (for service areas, nearest-neighbour zones).