Name

ST_Line_Substring — Returns a LineString being a portion of the input one. It will start and end at the given fractions of the total 2D length.

Synopsis

geometry ST_Line_Substring(bytea Geometry, double startFraction, double endFraction);

Alias

Line_Substring

Description

Returns a LineString being a portion of the input one. It will start and end at the given fractions of the total 2D length. The fractions parameters are numbers between 0 and 1.

MultiLineStrings are also supported. Jaspa returns a substring of a MultiLineString considering it as a whole, not cliping each of the LineStrings.

Coordinate Dimensions
2D3DM
Spatial Standards Support
OGC SFS for SQL. 1.1 (1999)OGC SFS for SQL. 1.1.0 (2005)OGC SFS for SQL. 1.2.0 (2006)SQL-MM Part 3
----

Examples

--2D LineString
SELECT ST_AsEWKT(ST_Line_Substring(ST_GeomFromEWKT('LINESTRING (17 21, 26 39, 44 46)'),0.2,0.8));
--Result
LINESTRING (20.527425830535137 28.05485166107027, 26 39, 36.64875355835534 43.14118193936041)

--4D LineString
SELECT ST_AsEWKT(ST_Line_Substring(ST_GeomFromEWKT('LINESTRING (17 21 10 -2, 26 39 15 -4, 44 46 20 -2)'),0.2,0.8));
--Result
LINESTRING (20.527425830535137 28.05485166107027 11.959681016963964 -2.783872406785585, 
26 39 15 -4, 36.64875355835534 43.14118193936041 17.95798709954315 -2.81680516018274)

--2D MultiLineString
SELECT ST_AsEWKT(ST_Line_Substring(ST_GeomFromEWKT('MULTILINESTRING ((1 1, 1 5), 
  (2 5, 4 5),(5 5, 5 1))'),0.2,0.8));
--Result
MULTILINESTRING ((1 3, 1 5), (2 5, 4 5), (5 5, 5 3))
ST_Line_Substring(Line,0.2,0.8)
ST_Line_Substring(MultiLineString,0.2,0.8)

Related functions

ST_Length,ST_Line_Interpolate_Point