ST_ExteriorRing
What is ST_ExteriorRing?
ST_ExteriorRing is a PostGIS function that returns the outer shell of a POLYGON as a closed LINESTRING. It does not include interior ring (hole) geometry.
ST_ExteriorRing(geometry polygon) → geometryOnly POLYGON input is supported — MULTIPOLYGON or other types return NULL. SRID and dimensionality are preserved; the result is always closed (first equals last vertex).
When would you use ST_ExteriorRing?
Use ST_ExteriorRing to extract just the outer boundary of a polygon — for example when drawing outlines, computing perimeter ignoring holes, or using the ring as input to ST_MakeLine edits:
1SELECT id,
2 ST_Length(ST_ExteriorRing(geom)) AS outer_perimeter_m
3FROM parcels
4WHERE GeometryType(geom) = 'POLYGON';For polygons with holes, ST_ExteriorRing discards them; use ST_Boundary to get every ring (exterior plus interior) combined.
FAQs
How is ST_ExteriorRing different from ST_Boundary?
ST_ExteriorRing returns only the outer ring as a single LINESTRING. ST_Boundary returns all rings (exterior plus every hole) as a MULTILINESTRING when holes exist.
Can ST_ExteriorRing handle MultiPolygons?
No — it returns NULL on MULTIPOLYGON. Unpack first with ST_Dump or select individual components with ST_GeometryN.
Is the output a closed LineString?
Yes. The first and last vertices coincide. Use ST_IsClosed or ST_IsRing to verify.
What SRID does the output have?
Same as the input polygon. Dimensionality (Z, M) is preserved at each ring vertex.