All Products
Search
Document Center

PolarDB:ST_LineSubstring

Last Updated:Mar 28, 2026

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

ParameterDescription
aLinestringThe LineString to extract a substring from.
startfractionThe start position as a fraction of the total length.
endfractionThe end position as a fraction of the total length.

Usage notes

  • When startfraction and endfraction are 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)