Returns a substring of a LineString between two fractional positions along its length.
Syntax
geometry ST_LineSubstring(geometry aLinestring , float8 startfraction , float8 endfraction);
geography ST_LineSubstring(geography aLinestring , float8 startfraction , float8 endfraction);Parameters
| Parameter | Description |
|---|---|
aLinestring | The LineString to extract a substring from. |
startfraction | The start position as a fraction of the total length. |
endfraction | The end position as a fraction of the total length. |
Usage notes
When
startfractionandendfractionare equal, the function behaves the same as ST_LineInterpolatePoint.To extract a substring from a MultiLineString, first merge it into a single LineString using
ST_LineMerge.3D objects are supported. Z coordinates are preserved in the output.
M coordinates are supported.
Examples
SELECT ST_AsText(ST_LineSubstring('LINESTRING(0 0,10 10)'::geometry,0.3,0.6));
st_astext
---------------------
LINESTRING(3 3,6 6)
(1 row)
--geography
SELECT ST_AsText(ST_LineSubstring('LINESTRING(0 0,10 10)'::geography,0.3,0.6));
st_astext
--------------------------------------------------------------------------------
LINESTRING(2.97227762767668 3.01417970957332,5.96094221033023 6.0199989936211)