Description
The ST_Length
function calculates and returns the geographic length of a
line or polyline geometry object in the desired unit type.
Syntax
ST_Length(WritableGeometry geometry, String linearUnits, [String computationType])
Parameters
Parameter |
Type |
Description |
geometry
|
WritableGeometry |
The input geometry. |
linearUnits
|
String |
The desired return unit type. For valid values, see Linear Units. |
computationType
|
String |
Optional. Indicates the logic to be used to interpret geometry coordinates. The
computation type is based on the coordinate system of the geometry being operated
on:
- For geographic (long/lat) coordinate systems: Valid type =
SPHERICAL (default)
- For projected coordinate systems: Valid types =
CARTESIAN ,
SPHERICAL (default)
- For engineering coordinate systems: Valid type =
CARTESIAN
(default)
- CARTESIAN
- The geometry coordinates are interpreted using cartesian logic.
- SPHERICAL
- The geometry coordinates are interpreted using spherical logic.
|
Linear Units
Valid values for unit type:
Value |
Description |
mi |
miles |
km |
kilometers |
in |
inches |
ft |
feet |
yd |
yards |
mm |
millimeters |
cm |
centimeters |
m |
meters |
survey ft |
US Survey feet |
nmi |
nautical miles |
Return Values
Return Type |
Description |
Double |
The length of the geometry. |
Examples
SELECT ST_Length(ST_GeomFromWkt(t.geometry,'epsg:4267'), 'm', 'SPHERICAL') FROM table t;
SELECT ST_Length(ST_GeomFromWkt(t.geometry,'epsg:4267'), 'm') FROM table t;