ST_Length
Determine the length of the linestring or multilinestring geometry.
Function takes WKB (Well Known Binary) as an input. Geometries must be specified by their latitude and longitude on a spherical earth model.
Syntax
ST_Length(geo[, unit[, cSys]]);
- geo
- The input geometry.
Type: VARCHAR(ANY)
- unit
- The units. Possible values include 'meter', 'kilometer', 'foot', 'mile', and 'nautical
mile'.
Type: VARCHAR(ANY)
Default: 'meter'
- cSys
- The coordinate system.
Type: VARCHAR(ANY)
Default: The coordinate system of the input geometry's SRID or, if the input geometry has no SRID, 'WGS84'.
Returns
A value of type DOUBLE that is the length of the line.
Examples
SELECT inza..ST_Length(inza..ST_WKTToSQL('LINESTRING(0 0, 3 4, -1 1)'), 'meter', 'cartesian');
ST_LENGTH
-----------
10
(1 row)
SELECT inza..ST_Length(inza..ST_WKTToSQL('MULTILINESTRING((0 0, 3 4, -1 1), (100 100, 400 500, 800 800))'), 'meter', 'cartesian');
ST_LENGTH
-----------
1010
(1 row)
SELECT inza..ST_Length(inza..ST_WKTToSQL('MULTILINESTRING((0 0, 1 0), (0 1, 1 0))', 4326));
ST_LENGTH
-----------
268219.05906783
(1 row)