All Products
Search
Document Center

PolarDB:ST_LineSubstring

Last Updated:Mar 28, 2026

Returns the part of a line between two fractional locations.

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.
endfractionThe end position.

Usage notes

  • If startfraction and endfraction are equal, the function behaves identically to ST_LineInterpolatePoint.

  • To extract a substring from a MultiLineString, first use ST_LineMerge to merge its LineStrings into a single LineString.

  • 3D objects are supported. z coordinates are preserved.

  • m coordinates are supported.

Examples

Geometry

Extract the middle third of a line using the geometry type.

SELECT ST_AsText(ST_LineSubstring('LINESTRING(0 0,10 10)'::geometry, 0.3, 0.6));

Result:

      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));

Result:

                               st_astext
--------------------------------------------------------------------------------
 LINESTRING(2.97227762767668 3.01417970957332,5.96094221033023 6.0199989936211)

See also