Skip to content
🎉 Apache Sedona 1.8.1 is now available! Check out the new features and improvements.

ST_Perimeter2D

Introduction: This function calculates the 2D perimeter of a given geometry. It supports Polygon, MultiPolygon, and GeometryCollection geometries (as long as the GeometryCollection contains polygonal geometries). For other types, it returns 0. To measure lines, use ST_Length.

To get the perimeter in meters, set use_spheroid to true. This calculates the geodesic perimeter using the WGS84 spheroid. When using use_spheroid, the lenient parameter defaults to true, assuming the geometry uses EPSG:4326. To throw an exception instead, set lenient to false.

Info

This function is an alias for ST_Perimeter.

Format:

ST_Perimeter2D(geom: Geometry)

ST_Perimeter2D(geom: Geometry, use_spheroid: Boolean)

ST_Perimeter2D(geom: Geometry, use_spheroid: Boolean, lenient: Boolean = True)

SQL Example:

SELECT ST_Perimeter2D(
        ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))')
)

Output:

20.0

SQL Example:

SELECT ST_Perimeter2D(
        ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))', 4326),
        true, false
)

Output:

2216860.5497177234