This topic describes the ST_LineInterpolatePoints function. This function interpolates a point at one or more specified locations of a LineString object and returns the 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 LineString object. |
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. |
repeat | Specifies whether to allow the repeated interpolation of the point. Default value: true. |
Description
If you set the repeat parameter to True, this function interpolates a point at every location that is represented as a fraction along the line.
If the result is zero or one point, this function returns the result as a point object. Otherwise, this function returns the result as a MultiPoint object.
This function supports 3D objects and does not delete z coordinates.
This function supports M coordinates.
If the geographic coordinate system is used, the distance between points is calculated based on the spherical distance.
Examples
Calculates the coordinates of a point at a specified location on a given 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))
Interpolate a point with the repeat parameter set to False.
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)