Name

ST_ExteriorRing — Returns the exteriorRing of a Polygon

Synopsis

geometry ST_ExteriorRing(bytea Polygon);

Alias

ExteriorRing

Description

Returns the exteriorRing of a Polygon as LineString. It also works with Polygon or Multipolygon or GeometryCollection (containing Polygons). If the incoming geometry is a MULTIPOLYGON, it will return a MULTILINESTRING.

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
2.1.10.17.2.15.17.2.13.18.2.3

Examples

--4D Polygon
SELECT ST_AsEWKT(ST_ExteriorRing(ST_GeomFromText('POLYGON ((20 20 10 10, 50 30 10 10, 20 50 -4 2, 20 20 4 2))')));
--Result
LINESTRING (20 20 10 10, 50 30 10 10, 20 50 -4 2, 20 20 4 2)

--Multipolygon
SELECT ST_AsEWKT(ST_ExteriorRing(ST_GeomFromText('MULTIPOLYGON (((0 0, 0 150, 150 150, 150 0, 0 0)), 
  ((350 0, 230 0, 230 120, 350 120, 350 0)))')));
--Result
MULTILINESTRING ((0 0, 0 150, 150 150, 150 0, 0 0), (350 0, 230 0, 230 120, 350 120, 350 0))

--Polygon with a hole
SELECT ST_AsEWKT(ST_ExteriorRing(ST_GeomFromText('POLYGON ((20 20, 50 20, 50 50, 20 50, 20 20), 
  (30 40, 30 30, 40 30, 40 40, 30 40))')));
--Result
LINESTRING (20 20, 50 20, 50 50, 20 50, 20 20)

--LineString
SELECT ST_ExteriorRing(ST_GeomFromText('LINESTRING(10 50 50,10 20 55,10 0 50)'));
--Result
ERROR:  es.upv.jaspa.exceptions.JASPAException: The geometry must be a Polygon, a MultiPolygon or a GeometryCollection 
(made of some polygonal element/s): found LineString

Related functions

ST_Boundary,ST_InteriorRingN