ST_Length takes a linestring or multilinestring and returns its length.
Syntax
db2gse.ST_Length(c db2gse.ST_Curve)
db2gse.ST_Length(mc db2gse.ST_MultiCurve)
Return type
Double
Examples
A local ecologist is studying the migratory patterns of the salmon population in the county's waterways. The ecologist wants to obtain the length of all stream and river systems running through the county.
The following CREATE TABLE statement creates the WATERWAYS table. The ID and NAME columns identify each stream and river system that is stored in the table. The WATER column is a multilinestring because the river and stream systems are often an aggregate of several linestrings.
CREATE TABLE WATERWAYS (id integer, name varchar(128), water db2gse.ST_MultiLineString);
The following SELECT statement uses the ST_Length function to return the name and length of each waterway within the county.
SELECT name, db2gse.ST_Length(water) "Length" FROM WATERWAYS;
Figure 36 displays a the river and stream systems that lie within the county boundary.
Figure 36. Using ST_Length to determine the total length of the waterways in a county