# ST_ExteriorRing

## Definition

ST_ExteriorRing returns the exterior ring of a polygon as a linestring.

## Syntax

`sde.st_exteriorring (pl1 sde.st_geometry)`

ST_LineString

## Example

An ornithologist, wanting to study the bird population on several islands, knows that the feeding zone of the bird species she is interested in is restricted to the shoreline. As part of her calculation of the islands' carrying capacity, the ornithologist requires the islands' perimeters. Some of the islands are so large they have several lakes on them. However, the shoreline of the lakes is inhabited exclusively by another more aggressive bird species. Therefore, the ornithologist requires the perimeter of only the exterior ring of the islands.

The ID and name columns of the islands table identify each island, while the land polygon column stores the island's geometry.

```CREATE TABLE islands (id integer,
name varchar(32),
land sde.st_geometry);

INSERT INTO islands VALUES (
1,
'Bear',
sde.st_polygon ('polygon ((40 120, 90 120, 90 150, 40 150, 40 120),(50 130, 60 130, 60 140, 50 140, 50 130),
(70 130, 80 130, 80 140, 70 140, 70 130))', 0)
);

INSERT INTO islands VALUES (
2,
'Johnson',
sde.st_polygon ('polygon ((10 10, 50 10, 10 30, 10 10))', 0)
);```

The ST_ExteriorRing function extracts the exterior ring from 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 function.

Oracle

```SELECT SUM (sde.st_length (sde.st_exteriorring (land)))
FROM ISLANDS;

SUM(ST_LENGTH(ST_EXTERIORRING(LAND)))

264.72136```

PostgreSQL

```SELECT SUM (sde.st_length (sde.st_exteriorring (land)))
FROM islands;

sum

264.721359549996```

The exterior rings of the islands represent the ecological interface each island shares with the sea.

2/5/2013