定义
ST_Perimeter 返回形成闭合面或多面要素的边界的连续线的长度。
此函数为 10.8.1 版本的新功能。
语法
每个部分中的前两个选项将以为要素所定义的坐标系为单位返回周长。后两个选项可用于指定线性测量单位。有关 linear_unit_name 的受支持的值列表,请参阅 ST_Distance。
Oracle 和 PostgreSQL
sde.st_perimeter (polygon sde.st_geometry)
sde.st_perimeter (multipolygon sde.st_geometry)
sde.st_perimeter (polygon sde.st_geometry, linear_unit_name text)
sde.st_perimeter (multipolygon sde.st_geometry, linear_unit_name text)
SQLite
st_perimeter (polygon sde.st_geometry)
st_perimeter (multipolygon sde.st_geometry)
st_perimeter (polygon sde.st_geometry, linear_unit_name text)
st_perimeter (multipolygon sde.st_geometry, linear_unit_name text)
返回类型
双精度型
示例
Oracle
在以下示例中,研究海岸线鸟类的生态学家需要确定特定区域内湖泊的海岸线长度。湖泊将在 waterbodies 表中存储为面。一个使用 ST_Perimeter 函数的 SELECT 语句将用于在 waterbodies 表中返回每个湖(要素)的周长。
--Create table named waterbodies
CREATE TABLE waterbodies (wbid INTEGER not null, waterbody sde.st_geometry);
--Insert a polygon feature to the waterbodies table
INSERT INTO waterbodies VALUES (
1,
sde.ST_Polygon ('polygon ((0 0, 0 4, 5 4, 5 0, 0 0))', 1)
);
--Find the perimeter of the polygon
SELECT sde.ST_Perimeter (waterbody)
FROM waterbodies;
SELECT 语句返回如下内容:
ID PERIMETER 1 +1.8000000
在下一个示例中,您将创建一个名为 bfp 的表,插入三个要素,并以线性测量单位计算每个要素的周长:
--Create table named bfp
CREATE TABLE bfp (
building_id integer not null,
footprint sde.st_geometry);
--Insert polygon features to the bfp table
INSERT INTO BFP (building_id, footprint) VALUES (
1,
sde.st_polygon ('polygon ((0 0, 0 10, 10 10, 10 0, 0 0))', 4326)
);
INSERT INTO BFP (building_id, footprint) VALUES (
2,
sde.st_polygon ('polygon ((20 0, 30 20, 40 0, 20 0))', 4326)
);
INSERT INTO BFP (building_id, footprint) VALUES (
3,
sde.st_polygon ('polygon ((20 30, 25 35, 30 30, 20 30))', 4326)
);
--Find the perimeter of each polygon
SELECT sde.ST_Perimeter(footprint)
,sde.ST_Perimeter(footprint, 'meter') as Meter
,sde.ST_Perimeter(footprint, 'km') as KM
,sde.ST_Perimeter(footprint, 'yard') As Yard
FROM bfp;
SELECT 语句以三个单位返回每个要素的周长:
st_perimeter | meter | km | yard -------------------+-------------------+--------------------+-------------------- 40.00000000000001 | 4421256.128972424 | 4421.256128972425 | 4835144.49800134 64.7213595499958 | 7159231.951087892 | 7159.2319510878915 | 7829431.267593933 24.14213562373095 | 2417672.365575198 | 2417.672365575198 | 2643998.6500166208
PostgreSQL
在以下示例中,研究海岸线鸟类的生态学家需要确定特定区域内湖泊的海岸线长度。湖泊将在 waterbodies 表中存储为面。一个使用 ST_Perimeter 函数的 SELECT 语句将用于在 waterbodies 表中返回每个湖(要素)的周长。
--Create table named waterbodies
CREATE TABLE waterbodies (wbid INTEGER not null, waterbody sde.st_geometry);
--Insert a polygon feature to the waterbodies table
INSERT INTO waterbodies VALUES (
1,
sde.ST_Polygon ('polygon ((0 0, 0 4, 5 4, 5 0, 0 0))', 1)
);
--Find the perimeter of the polygon
SELECT sde.ST_Perimeter (waterbody)
FROM waterbodies;
SELECT 语句返回如下内容:
ID PERIMETER 1 +1.8000000
在下一个示例中,您将创建一个名为 bfp 的表,插入三个要素,并以线性测量单位计算每个要素的周长:
--Create table named bfp
CREATE TABLE bfp (
building_id serial,
footprint sde.st_geometry);
--Insert polygon features to the bfp table
INSERT INTO bfp (footprint) VALUES (
sde.st_polygon ('polygon ((0 0, 0 10, 10 10, 10 0, 0 0))', 4326)
);
INSERT INTO bfp (footprint) VALUES (
sde.st_polygon ('polygon ((20 0, 30 20, 40 0, 20 0))', 4326)
);
INSERT INTO bfp (footprint) VALUES (
sde.st_polygon ('polygon ((20 30, 25 35, 30 30, 20 30))', 4326)
);
--Find the perimeter of each polygon
SELECT sde.st_perimeter(footprint)
,sde.st_perimeter(footprint, 'meter') as Meter
,sde.st_perimeter(footprint, 'km') as KM
,sde.st_perimeter(footprint, 'yard') As Yard
FROM bfp;
SELECT 语句以三个单位返回每个要素的周长:
st_perimeter | meter | km | yard -------------------+-------------------+--------------------+-------------------- 40.00000000000001 | 4421256.128972424 | 4421.256128972425 | 4835144.49800134 64.7213595499958 | 7159231.951087892 | 7159.2319510878915 | 7829431.267593933 24.14213562373095 | 2417672.365575198 | 2417.672365575198 | 2643998.6500166208
SQLite
在以下示例中,研究海岸线鸟类的生态学家需要确定特定区域内湖泊的海岸线长度。湖泊将在 waterbodies 表中存储为面。一个使用 ST_Perimeter 函数的 SELECT 语句将用于在 waterbodies 表中返回每个湖(要素)的周长。
--Create table named waterbodies and add a spatial column (waterbody) to it
CREATE TABLE waterbodies (wbid integer primary key autoincrement not null
);
SELECT AddGeometryColumn(
NULL,
'waterbodies',
'waterbody',
4326,
'polygon',
'xy',
'null'
);
--Insert a polygon feature to the waterbodies table
INSERT INTO waterbodies VALUES (
1,
ST_Polygon ('polygon ((0 0, 0 4, 5 4, 5 0, 0 0))', 1)
);
--Find the perimeter of the polygon
SELECT ST_Perimeter (waterbody)
FROM waterbodies;
SELECT 语句返回如下内容:
ID PERIMETER 1 +1.8000000
在下一个示例中,您将创建一个名为 bfp 的表,插入三个要素,并以线性测量单位计算每个要素的周长:
--Create table named bfp and add a spatial column (footprints) to it
CREATE TABLE bfp (
building_id integer primary key autoincrement not null
);
SELECT AddGeometryColumn(
NULL,
'bfp',
'footprint',
4326,
'polygon',
'xy',
'null'
);
--Insert polygon features to the bfp table
INSERT INTO bfp (footprint) VALUES (
st_polygon ('polygon ((0 0, 0 10, 10 10, 10 0, 0 0))', 4326)
);
INSERT INTO bfp (footprint) VALUES (
st_polygon ('polygon ((20 0, 30 20, 40 0, 20 0))', 4326)
);
INSERT INTO bfp (footprint) VALUES (
st_polygon ('polygon ((20 30, 25 35, 30 30, 20 30))', 4326)
);
--Find the perimeter of each polygon
SELECT ST_Perimeter(footprint)
,ST_Perimeter(footprint, 'meter') as Meter
,ST_Perimeter(footprint, 'km') as KM
,ST_Perimeter(footprint, 'yard') As Yard
FROM bfp;
SELECT 语句以三个单位返回每个要素的周长:
st_perimeter | meter | km | yard -------------------+-------------------+--------------------+-------------------- 40.00000000000001 | 4421256.128972424 | 4421.256128972425 | 4835144.49800134 64.7213595499958 | 7159231.951087892 | 7159.2319510878915 | 7829431.267593933 24.14213562373095 | 2417672.365575198 | 2417.672365575198 | 2643998.6500166208