Skip to content

ST_Length

Returns the length of a geometry or geography.

Usage

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

Arguments

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

Description

Returns the length of geom. This function only supports LineString, MultiLineString, and GeometryCollections containing linear geometries. Use ST_Perimeter for polygons. For geometry, returns the length in the units of the coordinate reference system; for geography, returns the spherical approximation of the geodesic length in meters.

Examples

SELECT ST_Length(ST_GeomFromWKT('LINESTRING (0 0, 0 1)'));
┌──────────────────────────────────────────────────────────┐
│ st_length(st_geomfromwkt(Utf8("LINESTRING (0 0, 0 1)"))) │
│                          float64                         │
╞══════════════════════════════════════════════════════════╡
│                                                      1.0 │
└──────────────────────────────────────────────────────────┘
SELECT ST_Length(ST_GeogFromWKT('LINESTRING (0 0, 0 1)'));
┌──────────────────────────────────────────────────────────┐
│ st_length(st_geogfromwkt(Utf8("LINESTRING (0 0, 0 1)"))) │
│                          float64                         │
╞══════════════════════════════════════════════════════════╡
│                                       111195.10117748393 │
└──────────────────────────────────────────────────────────┘