The ST_Perimeter() function
The ST_Perimeter() function returns the perimeter of a polygon or multipolygon.
Syntax
ST_Perimeter(s ST_Polygon)
ST_Perimeter(s ST_Polygon, linear_uom varchar(128))
ST_Perimeter(ms ST_MultiPolygon)
ST_Perimeter(ms ST_MultiPolygon, linear_uom varchar(128))
ST_Perimeter(s ST_Polygon)
ST_Perimeter(ms ST_MultiPolygon)
The linear_uom parameter converts the result to the specified unit of measure. To calculate the perimeter if the polygon is in a geographic coordinate system where the coordinates are in an angular unit of measure, you must specify a linear unit of measure with the linear_uom parameter. Angular units of measure are converted to linear units of measure by great-circle calculations. If the polygon is in a projected coordinate system that has a unit of measure that is different from the unit of measure that is specified by the linear_uom parameter, then the returned value is converted to the unit of measure that is specified by the linear_uom parameter. The linear_uom parameter must be the name of a linear unit of measure from the unit_name column of the st_units_of_measure table.
Return type
DOUBLE PRECISION
Example: Find the perimeter of lakes
CREATE TABLE WATERBODIES (wbid integer, waterbody ST_MultiPolygon);
SELECT SUM(ST_Perimeter(waterbody)) FROM waterbodies;
Examples: Find the perimeter polygons
The following statement returns the perimeter of a polygon in meters:
execute function round(
st_perimeter(
'32608 polygon((576100 15230, 576100 15232, 576102 15232,
576102 15230, 576100 15230))'::st_polygon,
'meter'),
2);
(expression)
8.00000000000000
1 row(s) retrieved.
The following statement returns the perimeter of a multipolygon in meters:
EXECUTE FUNCTION round(
st_perimeter(
'32608 multipolygon(((576100 15230, 576100 15232, 576102 15232,
576102 15230, 576100 15230)),((576104 4, 576104 6, 576106 6,
576106 4, 576104 4)))'::st_multipolygon,
'meter'),
2);
(expression)
16.0000000000000
1 row(s) retrieved.
Example: Find the perimeter of a polygon that is based on angular coordinates
The following statement returns the perimeter distance in meters of a 10 kilometer buffer around the coordinates from the angular coordinate system WGS 84, which has SRID 4326, that represent the latitude and longitude of New York (73.94000 W, 40.67000 N):
EXECUTE FUNCTION ST_perimeter(ST_Buffer('4326 point(-73.94000 40.67000)'
::st_point, 10, 'kilometer')::st_polygon, 'meter');
(expression)
62820.61328130
1 row(s) retrieved.