All Products
Search
Document Center

ApsaraDB RDS:ST_LineInterpolatePoints

Last Updated:Oct 09, 2026

Inserts one or more points at specified positions on a LineString and returns the inserted points.

Syntax

geometry  ST_LineInterpolatePoints(geometry  aLinestring , float8  aFraction , boolean  repeat);
geography  ST_LineInterpolatePoints(geography  aLinestring , float8  aFraction , boolean  repeat);

Parameters

Parameter

Description

aLinestring

The target LineString object.

aFraction

The percentage along the line segment at which the point is inserted. It is a floating-point value from 0 to 1.

repeat

Specifies whether to insert points repeatedly. Default value: true.

Description

  • If repeat is set to true, a point is created at every specified distance.

  • If the result contains zero or one point, it is returned as a Point. Otherwise, it is returned as a MultiPoint.

  • This function supports 3D objects and does not delete the Z coordinate.

  • This function supports M coordinates.

  • When a geographic coordinate system is used, the calculation is based on spherical distance.

Examples

  • Calculate the point coordinates at a specified fraction of the given line segment:

    SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)', 0.20));
                st_astext
    ---------------------------------
     MULTIPOINT(0 1,0 2,0 3,0 4,0 5)
    (1 row)
    
    -- gepgraphy
    SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)'::geography, 0.20));
                                                   st_astext                                               
    -------------------------------------------------------------------------------------------------------
     MULTIPOINT((0 1.00002443285827),(0 2.00004274948544),(0 3.00004884128919),(0 4.00003661494431),(0 5))
  • Without repeated insertion:

    SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)', 0.20, false));
     st_astext
    ------------
     POINT(0 1)
    (1 row)
    
    SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)'::geography, 0.20, false));
             st_astext         
    ---------------------------
     POINT(0 1.00002443285827)
    (1 row)