The PostGIS ST_DumpPoints function seems to have enough data in the return value about the structure of geometries (in the path field):

It returns a set of geometry_dump rows, each containing a geometry (geom field) and an array of integers (path field).

  • the geom field POINTs represent the coordinates of the supplied geometry.

  • the path field (an integer[]) is an index enumerating the coordinate positions in the elements of the supplied geometry. The indices are 1-based. For example, for a LINESTRING the paths are {i} where i is the nth coordinate in the LINESTRING. For a POLYGON the paths are {i,j} where i is the ring number (1 is outer; inner rings follow) and j is the coordinate position in the ring.

Is there a function in PostGIS to reconstruct a specific type of geometry (e.g. MULTIPOLYGON, or LINESTRING) from its point dump table to get back the original geometry?

(I know ST_MakeLine, but I was wondering if there is a more general inverse of ST_Dump type functions.)

1 Answer 1



You will have to manually aggregate the dumped Point geometries according to their index and unique (row) identifier, and in a dimensional bottom-up fashion - and you will need n-1 aggregation steps for n elements in the returned path array, to reconstruct the original geometry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.