Categories:

Geospatial Functions

ST_LENGTH

Returns the geodesic length in meters of the linestring(s) in a GEOGRAPHY object.

Syntax

ST_LENGTH( <geography_expression> )

Arguments

geography_expression

The argument must be of type GEOGRAPHY.

Returns

Returns a REAL value, which represents the length in meters.

Usage Notes

  • If geography_expression is not a LineString, MultiLineString, or GeometryCollection containing linestrings, ST_LENGTH returns 0.

  • If geography_expression is a GeometryCollection, ST_LENGTH returns the sum of the lengths of the linestrings in the collection.

  • If you want the perimeter length of a polygon, use the ST_PERIMETER function instead.

Examples

This shows the length in meters of one degree of arc at the equator:

SELECT ST_LENGTH(TO_GEOGRAPHY('LineString(0.0 0.0, 1.0 0.0)'));
+---------------------------------------------------------+
| ST_LENGTH(TO_GEOGRAPHY('LINESTRING(0.0 0.0, 1.0 0.0)')) |
|---------------------------------------------------------|
|                                        111195.101177484 |
+---------------------------------------------------------+