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

An ecologist who studies shoreline birds needs to determine the shoreline for the lakes within a particular area. The lakes are stored as ST_MultiPolygon type in the waterbodies table, created with the following CREATE TABLE statement:
CREATE TABLE WATERBODIES (wbid integer, waterbody ST_MultiPolygon);
In the following SELECT statement, the ST_Perimeter() function returns the perimeter that surrounds each body of water, while the SUM operator aggregates the perimeters to return their total:
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.