Definition
ST_Perimeter returns the length of the continuous line that forms the boundary of a closed polygon or multipolygon feature.
This function is new in 10.8.1.
Syntax
The first two options in each section return the perimeter in the units of the coordinate system defined for the feature. The second two options allow you to specify the linear unit of measure. For a list of supported values for linear_unit_name, see ST_Distance.
Oracle and 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)
Return type
Double precision
Examples
Oracle
In the following example, an ecologist studying shoreline birds needs to determine the length of the shoreline for the lakes in a particular area. The lakes are stored as polygons in the waterbodies table. A SELECT statement using the ST_Perimeter function is used to return the perimeter of each lake (feature) in the waterbodies table.
--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;
The SELECT statement returns the following:
ID PERIMETER 1 +1.8000000
In the next example, you will create a table named bfp, insert three features, and calculate the perimeter of each feature in units of linear measure:
--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;
The SELECT statement returns the perimeter of each feature in three units:
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
In the following example, an ecologist studying shoreline birds needs to determine the length of the shoreline for the lakes in a particular area. The lakes are stored as polygons in the waterbodies table. A SELECT statement using the ST_Perimeter function is used to return the perimeter of each lake (feature) in the waterbodies table.
--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;
The SELECT statement returns the following:
ID PERIMETER 1 +1.8000000
In the next example, you will create a table named bfp, insert three features, and calculate the perimeter of each feature in units of linear measure:
--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;
The SELECT statement returns the perimeter of each feature in three units:
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
In the following example, an ecologist studying shoreline birds needs to determine the length of the shoreline for the lakes in a particular area. The lakes are stored as polygons in the waterbodies table. A SELECT statement using the ST_Perimeter function is used to return the perimeter of each lake (feature) in the waterbodies table.
--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;
The SELECT statement returns the following:
ID PERIMETER 1 +1.8000000
In the next example, you will create a table named bfp, insert three features, and calculate the perimeter of each feature in units of linear measure:
--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;
The SELECT statement returns the perimeter of each feature in three units:
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