All Products
Search
Document Center

ApsaraDB RDS:ST_Perimeter

Last Updated:Mar 28, 2026

Calculates the 2D perimeter of a geometry or geography object.

Syntax

float ST_Perimeter(geometry g1);
float ST_Perimeter(geography geog, boolean useSpheroid);

Parameters

ParameterDescription
g1The geometry object.
geogThe geography object.
useSpheroidSpecifies whether to use an ellipsoid.

Usage notes

  • For ST_Surface and ST_MultiSurface objects (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