ST_DumpPoints
What is ST_DumpPoints?
ST_DumpPoints is a set-returning PostGIS function that expands a geometry into one row per vertex. Each row contains a path integer array (position within nested geometry structure) and the vertex as a POINT.
ST_DumpPoints(geometry g) → setof geometry_dump(path integer[], geom geometry)Applicable to every geometry type. For polygons, rings are traversed in storage order (exterior first, then interior). Z and M values on vertices are preserved in the point output.
When would you use ST_DumpPoints?
Use ST_DumpPoints to get all vertices of a geometry as individual points for analysis — computing per-vertex statistics, finding extreme points, or reconstructing modified geometries:
1SELECT track_id, (dp).path[1] AS vertex_idx,
2 ST_X((dp).geom) AS x, ST_Y((dp).geom) AS y
3FROM (
4 SELECT track_id, ST_DumpPoints(geom) AS dp
5 FROM gps_tracks
6) t
7ORDER BY track_id, vertex_idx;Also the standard way to export vertex-level CSVs from a spatial table, or to build a point layer from existing linear/polygonal features for sampling or interpolation.
FAQs
How do I read the path array?
For a LINESTRING, path = '{vertex_number}'. For a POLYGON, path = '{ring_number, vertex_number}'. For a MULTIPOLYGON, path = '{polygon_number, ring_number, vertex_number}'. It gives you exact coordinates within the nested geometry.
Does ST_DumpPoints include the closing vertex of polygon rings?
Yes. The closing vertex (identical to the first) is emitted because it is part of the stored coordinate sequence. Drop it if your downstream logic dedupes by coordinate.
What is the difference from ST_Points?
ST_Points returns a single MULTIPOINT containing every vertex. ST_DumpPoints returns one row per vertex with its path. Use ST_Points for vertex sets as a single value; use ST_DumpPoints when you need row-level indexing.
Are Z and M preserved?
Yes. Each emitted point carries the full dimensionality of the source vertex, accessible with ST_Z and ST_M.