All Products
Search
Document Center

ApsaraDB RDS:ST_LineInterpolatePoint

Last Updated:Mar 28, 2026

Returns a point interpolated along a LineString at the specified fractional position.

Syntax

geometry  ST_LineInterpolatePoint(geometry  aLinestring, float8  aFraction);
geography ST_LineInterpolatePoint(geography aLinestring, float8  aFraction);

Parameters

ParameterDescription
aLinestringThe LineString object to interpolate along.
aFractionThe fractional position along the line, as a float8 value in the range [0, 1]. A value of 0 returns the start point; 1 returns the end point.

Usage notes

  • 3D and M coordinate support: The function supports 3D objects and does not delete z coordinates. The function also supports m coordinates.

  • Geography type: If the geographic coordinate system is used, the distance between points is calculated based on the spherical distance.

Examples

Get the midpoint of a line

Pass 0.5 as aFraction to get the point at the halfway mark.

Geometry:

SELECT ST_AsText(ST_LineInterpolatePoint(geom, 0.5))
FROM (SELECT 'LINESTRING(0 0,2 2)'::geometry AS geom) AS test;

Result:

 st_astext
------------
 POINT(1 1)
(1 row)

Geography (distances measured along the spheroid, so the result differs slightly from the planar midpoint):

SELECT ST_AsText(ST_LineInterpolatePoint(geog, 0.5))
FROM (SELECT 'LINESTRING(0 0,2 2)'::geography AS geog) AS test;

Result:

 POINT(0.99969732796684 1.00015638159834)

Find the closest point on a line to an external point

Combine ST_LineInterpolatePoint with ST_LineLocatePoint to project an external point onto a line and return the nearest point on that line.

Geometry:

SELECT ST_AsText(ST_LineInterpolatePoint(geom, ST_LineLocatePoint(geom, 'POINT(1 1)'::geometry)))
FROM (SELECT 'LINESTRING(0 0,0 2)'::geometry AS geom) AS test;

Result:

 st_astext
------------
 POINT(0 1)
(1 row)

Geography:

SELECT ST_AsText(ST_LineInterpolatePoint(geog, ST_LineLocatePoint(geog, 'POINT(1 1)'::geography)))
FROM (SELECT 'LINESTRING(0 0,0 2)'::geography AS geog) AS test;

Result:

 POINT(0 1.00015229710421)

What's next

  • ST_LineLocatePoint — returns the fractional position along a line closest to a given point (the inverse of this function)