12345678910111213141516171819202122232425262728 |
- -- An ornithologist, wishing to study the bird population on several south
- -- sea 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 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 shoreline 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);
- INSERT INTO islands VALUES(
- 1,
- 'hawaii',
- ST_PolyFromText('polygon ((42000 18000,48000 18000,48000 13000,42000 13000,42000 18000))',1000)
- );
- -- 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.
- SELECT SUM(ST_Length(ST_ExteriorRing(land)))
- FROM islands;
|