The ST_PointAtDistance() function

The ST_PointAtDistance() function returns the point the specified distance from the start of the line. Z coordinates and measures are ignored.

Syntax

ST_PointAtDistance (ST_LineString, float)
ST_PointAtDistance (ST_MultiLineString, float)

Return type

ST_Point

Example

The following SQL statement creates the sample_geometries table with two columns. The ID column uniquely identifies each row. The geometry ST_LineString column stores sample geometries.

CREATE TABLE sample_geometries(id INTEGER, geometry ST_LINESTRING);

The following SQL statement inserts two rows into the sample_geometries table:

INSERT INTO sample_geometries(id, geometry)
VALUES
 (1,ST_LineString('LINESTRING ZM(0 0 0 0, 10 100 1000 10000)',1)),
 (2,ST_LineString('LINESTRING ZM(10 100 1000 10000, 0 0 0 0)',1));

The following SELECT statement and the corresponding result set show how to use the ST_PointAtDistance() function to find points at a distance of 15 coordinate units from the start of the linestring.

SELECT ID, VARCHAR(ST_AsText(ST_PointAtDistance(geometry, 15)), 50) AS POINTAT 
FROM  sample_geometries;

ID          POINTAT                                           
----------- --------------------------------------------------
          1 POINT ZM(1.492556 14.925558 149 1493)             
          2 POINT ZM(8.507444 85.074442 851 8507)             

  2 record(s) selected.