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.
The ID and name columns
of the islands table identifies each island, while the land polygon
column stores the island's geometry:
CREATE TABLE islands (id integer,
name varchar(32),
land ST_Polygon);
The ST_ExteriorRing() function
extracts the exterior ring of each island polygon as a linestring.
The length of the linestring is calculated by the ST_Length() function.
The linestring lengths are summarized by the SUM operator:
SELECT SUM(ST_Length(ST_ExteriorRing(land)))
FROM islands;
As shown in the following figure,
the exterior rings of the islands represent the ecological interface
each island shares with the sea. Some of the islands have lakes, which
are represented by the interior rings of the polygons. Figure 1: Islands and lakes