Skip to content

ST_Perimeter

Calculates the perimeter of a given geometry or geography.

Usage

double ST_Perimeter(geom: geometry)
double ST_Perimeter(geog: geography)

Arguments

  • geog (geography): Input geography
  • geom (geometry): Input geometry

Description

This function calculates the perimeter of a given geometry or geography. 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. For geography, returns the spherical approximation of the geodesic perimeter in meters.

Examples

SELECT ST_Perimeter(ST_GeomFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'));
┌───────────────────────────────────────────────────────────────────────────┐
│ st_perimeter(st_geomfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│                                  float64                                  │
╞═══════════════════════════════════════════════════════════════════════════╡
│                                                                       4.0 │
└───────────────────────────────────────────────────────────────────────────┘
SELECT ST_Perimeter(ST_GeogFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))'));
┌───────────────────────────────────────────────────────────────────────────┐
│ st_perimeter(st_geogfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│                                  float64                                  │
╞═══════════════════════════════════════════════════════════════════════════╡
│                                                        444763.46872762055 │
└───────────────────────────────────────────────────────────────────────────┘