The ST_ExteriorRing() function
The ST_ExteriorRing() function returns the exterior ring of a polygon as a linestring.
Syntax
ST_ExteriorRing(pl1 ST_Polygon)
Return type
ST_LineString
Example
An ornithologist studying the bird population on several South Sea islands knows that the feeding zone of the bird species of interest is restricted to the shoreline. As part of the calculation of the island's carrying capacity, the ornithologist requires the islands' perimeters. Some of the islands are so large, they have several ponds on them. However, the shorelines of the ponds are inhabited exclusively by another more aggressive bird species. Therefore, the ornithologist requires the perimeter of the exterior ring only of the islands.
CREATE TABLE islands (id integer,
name varchar(32),
land ST_Polygon);
SELECT SUM(ST_Length(ST_ExteriorRing(land)))
FROM islands;
