Appearance
ST_LENGTH
Returns the length of a GEOGRAPHY linear feature in meters.
For non-linear types, such as points and polygons, the function returns 0.
See also:
Syntax
sql
ST_LENGTH(<input>[, <use_spheroid>])Arguments
<input>: TheGEOGRAPHYobject for which to compute the length<use_spheroid>: An optionalBOOLEAN. IfFALSE, calculations use a spherical approximation instead of a spheroid. Defaults toTRUE
Returns
Returns a FLOAT value representing the length in meters:
- For linear features (
LineStrings,MultiLineStrings): Returns the total length - For points and polygons: Returns
0
Example
sql
SELECT ST_Length('LINESTRING(0 0, 1 1)'::GEOGRAPHY);
-- 156899.56829134
SELECT ST_Length('POINT(0 0)'::GEOGRAPHY);
-- 0