All Products
Search
Document Center

ApsaraDB RDS:ST_LineSubstring

Last Updated:Sep 28, 2023

This topic describes the ST_LineSubstring function. This function returns the substring of a LineString object.

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 object that you want to specify.

startfraction

The start position.

endfraction

The end position.

Description

  • If the startfraction and endfraction parameters are set to the same value, this function serves the same as the ST_LineInterpolatePoint function.

  • Before you can obtain the substring of a MultiLineString object, you must use the ST_LineMerge function to merge the LineStrings of the MultiLineString object.

  • The ST_LineSubstring function supports 3D objects and does not delete z coordinates.

  • The ST_LineSubstring function supports m coordinates.

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)