ArcGIS Server Banner

ST_Length

ST_Length

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.

Definition

ST_Length returns the length of an ST_LineString or ST_MultiLinestring.

Syntax

Oracle

sde.st_length (ln1 sde.st_geometry)
sde.st_length (mln1 sde.st_geometry)

PostgreSQL

st_length (ln1 st_geometry)
st_length (mln1 st_geometry)

Return type

Double precision

Example

A local ecologist studying the migratory patterns of the salmon population in the county's waterways wants the length of all stream and river systems within the county.

The waterways table is created with the ID and name columns, which identify each stream and river system stored in the table. The water column is a multilinestring because the river and stream systems are often an aggregate of several linestrings.

Oracle

CREATE TABLE waterways (oid integer, name varchar(128), water sde.st_geometry);

INSERT INTO waterways VALUES (
1111,
'Genesee', 
sde.st_multilinestring ('multilinestring ((33 2, 34 3, 35 6),
(28 4, 29 5, 31 8, 43 12), (39 3, 37 4, 36 7))', 0)
);

PostgreSQL

CREATE TABLE waterways (oid integer, name varchar(128), water st_geometry);

INSERT INTO waterways VALUES (
1111,
'Genesee', 
st_multilinestring ('multilinestring ((33 2, 34 3, 35 6),
(28 4, 29 5, 31 8, 43 12), (39 3, 37 4, 36 7))', 0)
);

The query returns the name of each system along with the length of the system generated by the ST_Length function.

Oracle

SELECT name, sde.st_length (water) "Length"
FROM waterways;

NAME	Length

Genesee	27.6437123

PostgreSQL

SELECT name, st_length (water) AS "Length"
FROM waterways;

name	Length

Genesee	27.6437123

See Also

  • An overview of SQL functions used with ST_Geometry types