This topic describes the ST_LineInterpolatePoint function. This function interpolates a point at the specified location of a LineString object and returns the point.

Syntax

geometry  ST_LineInterpolatePoint(geometry  aLinestring , float8  aFraction);

Parameters

Parameter Description
aLinestring The LineString object that you want to specify.
aFraction The fraction based on which the point is interpolated into the line. The value of this parameter is a floating-point number within the range of 0 to 1.

Description

  • This function supports 3D objects and does not delete z coordinates.
  • This function supports m coordinates.

Examples

  • SELECT ST_AsText(ST_LineInterpolatePoint(geom, 0.5)) FROM (SELECT 'LINESTRING(0 0,2 2)'::geometry as geom) As test;
     st_astext
    ------------
     POINT(1 1)
    (1 row)
                        
  • Obtain the closest point on a line to a geometry object.
    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;
     st_astext
    ------------
     POINT(0 1)
    (1 row)