Name

ST_Length — Returns the 2-dimensional length of a Geometry.

Synopsis

double ST_Length(bytea Geometry);

Alias

Length, ST_Length2D, Length2D, ST_Perimeter, Perimeter

Description

Returns the 2d length of a Geometry. Linear geometries return their length. Areal geometries return their perimeter.

Spatial Standards OGC defines the function for LineStrings and MultiLineStrings. Jaspa adds support to areal Geometries.

[Note]

This function supports GeometryCollections.

Coordinate Dimensions
2D3DM

-

-

Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
2.1.5.1 , 2.1.7.17.2.12.1 , 7.2.17.17.2.10.2 , 7.2.17.2

7.1.2 , 9.3.4 Linear

8.1.3 , 9.5.4 Areal

Examples

SELECT ST_Length(ST_GeomFromText('LINESTRING (0 0, 10 10, 10 5, 15 10)'));
--Result
26.213203435596427

SELECT ST_Length2D(ST_GeomFromText('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'));
--Result
40.0

SELECT ST_Length(ST_GeomFromText('GEOMETRYCOLLECTION (POINT (40 30),LINESTRING (0 0, 10 10, 10 5, 15 10),POLYGON((0 0, 0 10, 10 10, 10 0, 0 0)))'));
--Result
66.21320343559643

Related functions

ST_Perimeter,ST_Length3D