ST_Length

Calculates the length of a spatial object. For GEOMETRY objects, the length is measured in Cartesian coordinate units. For GEOGRAPHY objects, the length is measured in meters.

Calculates the length as follows:

Note: ST_Length does not calculate the length of WKTs or WKBs. To calculate the lengths of those objects, use the Vertica LENGTH SQL function with ST_AsBinary or ST_AsText.

Behavior Type

Immutable

Syntax

ST_Length( g )

Arguments

g

Spatial object for which you want to calculate the length, type GEOMETRY or GEOGRAPHY

Returns

FLOAT

Supported Data Types

Data Type GEOMETRY GEOGRAPHY (Perfect Sphere)
Point Yes Yes
Multipoint Yes Yes
Linestring Yes Yes
Multilinestring Yes Yes
Polygon Yes Yes
Multipolygon Yes Yes
GeometryCollection

Yes

No

Examples

The following examples show how to use ST_Length.

Returns length in Cartesian coordinate units:

=> SELECT ST_Length(ST_GeomFromText('LINESTRING(-1 -1,2 2,4 5,6 7)'));
    ST_Length     
------------------
 10.6766190873295
(1 row)

Returns length in meters:

=> SELECT ST_Length(ST_GeographyFromText('LINESTRING(-56.12 38.26,-57.51 39.78,
   -56.37 45.24)'));
    ST_Length     
------------------
 821580.025733461
(1 row)