ST_DumpRings
What is ST_DumpRings?
ST_DumpRings is a set-returning PostGIS function that decomposes a POLYGON into its individual rings — the exterior ring and each interior ring — returning each one as a separate single-ring polygon.
ST_DumpRings(geometry polygon) → setof geometry_dump(path integer[], geom geometry)The path field identifies the ring: {0} for the exterior ring, {1} for the first hole, {2} for the second hole, and so on. Only POLYGON input is accepted — MULTIPOLYGON must be unpacked first with ST_Dump.
When would you use ST_DumpRings?
Use ST_DumpRings to operate on each ring of a polygon independently — computing hole areas separately from the outer shell, extracting holes for a cut-out layer, or validating that all rings are correctly oriented:
1SELECT parcel_id, (r).path[1] AS ring_idx,
2 ST_Area((r).geom) AS ring_area
3FROM (
4 SELECT parcel_id, ST_DumpRings(geom) AS r
5 FROM parcels
6 WHERE ST_NumInteriorRings(geom) > 0
7) t;Note that each emitted ring comes back as a polygon (single-ring), not a linestring — if you want the ring as a line, wrap with ST_ExteriorRing.
FAQs
Does ST_DumpRings work on MultiPolygon?
No. Input must be a POLYGON. Unpack a MULTIPOLYGON first: ST_DumpRings((ST_Dump(mp)).geom).
What is the first row's path?
path = '{0}' for the exterior ring. Hole rings follow as {1}, {2}, etc. in storage order.
What is the return geometry type per ring?
Each ring is returned as a single-ring POLYGON (not a LINESTRING). To get linestrings use ST_ExteriorRing on the result or combine with ST_Boundary.
How is this different from ST_InteriorRingN and ST_ExteriorRing?
Those return a specific ring by index as a LINESTRING. ST_DumpRings emits every ring as a polygon in one call. Use ST_DumpRings for set-based iteration, the others for targeted access.