定义
ST_ExteriorRing 以线串形式返回面的外部环。
语法
sde.st_exteriorring (polygon1 sde.st_geometry)
Oracle 和 PostgreSQL
sde.st_exteriorring (polygon1 sde.st_geometry)
SQLite
st_exteriorring (polygon1 geometryblob)
返回类型
ST_LineString
示例
鸟类学家想要研究多个岛屿上的鸟类种群,了解到的情况是她所感兴趣的鸟类物种的摄食区域限制在岸线地带。在计算岛屿的承载能力过程中,鸟类学家需要知道岛屿的周长。一些岛屿很大,上面有几个湖。但是,湖的岸线地带被另一个更具侵略性的鸟类物种所独占栖息。因此,鸟类学家只需要知道岛屿的外部环的周长。
islands 表的 ID 列和名称列标识每个岛屿,而陆地面列存储岛屿的几何。
ST_ExteriorRing 函数从每个岛屿面提取线串形式的外部环。线串的长度使用 ST_Length 函数计算。线串长度使用 SUM 函数汇总。
岛屿的外部环表示每个岛屿与海洋共有的生态分界面。
Oracle
--Create the table and insert two polygons.
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))', 4326)
);
INSERT INTO islands VALUES (
2,
'Johnson',
sde.st_polygon ('polygon ((10 10, 50 10, 10 30, 10 10))', 4326)
);
--Extract the exterior ring from each island and find its length.
SELECT SUM (sde.st_length (sde.st_exteriorring (land)))
FROM ISLANDS;
SUM(ST_LENGTH(ST_EXTERIORRING(LAND)))
264.72136
PostgreSQL
--Create the table and insert two polygons.
CREATE TABLE islands (
id serial,
name varchar(32),
land sde.st_geometry
);
INSERT INTO islands (name, land) VALUES (
'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))', 4326)
);
INSERT INTO islands (name, land) VALUES (
'Johnson',
sde.st_polygon ('polygon ((10 10, 50 10, 10 30, 10 10))', 4326)
);
--Extract the exterior ring from each island and find its length.
SELECT SUM (sde.st_length (sde.st_exteriorring (land)))
FROM islands;
sum
264.721359549996
SQLite
--Create the table and insert two polygons.
CREATE TABLE islands (
id integer primary key autoincrement not null,
name varchar(32)
);
SELECT AddGeometryColumn (
NULL,
'islands',
'land',
4326,
'polygon',
'xy',
'null'
);
INSERT INTO islands (name, land) VALUES (
'Bear',
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))', 4326)
);
INSERT INTO islands (name, land) VALUES (
'Johnson',
st_polygon ('polygon ((10 10, 50 10, 10 30, 10 10))', 4326)
);
--Extract the exterior ring from each island and find its length.
SELECT SUM (st_length (st_exteriorring (land)))
FROM islands;
sum
264.721359549996