Skip to content

ST_LineSubstring

Returns a linestring being a substring of the input one starting and ending at the given fractions of total 2d length.

Usage

geometry ST_LineSubstring(geom: geometry, start_fraction: double, end_fraction: double)

Arguments

  • geom (geometry): Input geometry
  • start_fraction (double): The fraction from which the returned line will start (between 0 and 1)
  • end_fraction (double): The fraction from which the returned line will end (between 0 and 1)

Examples

SELECT ST_AsText(
  ST_LineSubstring(
    ST_GeomFromWKT('LINESTRING(0 0, 10 10)'),
    0.3,
    0.6
  )
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_astext(st_linesubstring(st_geomfromwkt(Utf8("LINESTRING(0 0, 10 10)")),Fl │
│                          oat64(0.3),Float64(0.6)))…                          │
╞══════════════════════════════════════════════════════════════════════════════╡
│ LINESTRING(3 3,6 6)                                                          │
└──────────────────────────────────────────────────────────────────────────────┘