This topic describes the ST_Perimeter function. This function calculates the perimeter of a geometry object or geography object.
Syntax
float ST_Perimeter(geometry g1);
float ST_Perimeter(geography geog , boolean useSpheroid);
Parameters
Parameter | Description |
---|---|
g1 | The geometry object that you want to specify. |
geog | The geography object that you want to specify. |
useSpheroid | Specifies whether to use an ellipsoid. |
Description
- If the geometry or geography object that you specify is an ST_Surface object or an ST_MultiSurface object, the ST_Perimeter function returns the 2D perimeter of the object. An ST_MultiSurface object is a collection of surfaces, which can be polygons or MultiPolygons.
- If you specify a non-areal object, the ST_Perimeter function returns 0.
- If you want to calculate the perimeter of a linear geometry object, we recommend that you use the ST_Length function.
- If you specify a geometry object, the ST_Perimeter function returns the perimeter of the object in the unit that is specified by the spatial reference system of the object.
- If you specify a geography object, the ST_Perimeter function returns an inverse geodesic distance, which is measured in meters.
Examples
Calculate the perimeter of an object by using the default parameter settings.
SELECT ST_Perimeter('POLYGON((0 0,0 2,2 2,2 0,0 0))'::geometry);
st_perimeter
--------------
8
(1 row)