Calculates the 2D perimeter of a geometry or geography object.
Syntax
float ST_Perimeter(geometry g1);
float ST_Perimeter(geography geog, boolean useSpheroid);Parameters
| Parameter | Description |
|---|---|
g1 | The geometry object. |
geog | The geography object. |
useSpheroid | Specifies whether to use an ellipsoid. |
Usage notes
For
ST_SurfaceandST_MultiSurfaceobjects (polygons and MultiPolygons), the function returns the 2D perimeter.For non-areal objects (points, lines), the function returns
0. To measure the length of a LineString or MultiLineString, use ST_Length instead.For geometry input, the result is in the unit defined by the object's spatial reference system.
For geography input, the result is an inverse geodesic distance measured in meters.
Examples
SELECT ST_Perimeter('POLYGON((0 0,0 2,2 2,2 0,0 0))'::geometry);
st_perimeter
--------------
8
(1 row)See also
ST_Length — measures the length of a LineString or MultiLineString