PostGIS Point Creation – Creating Point at Defined Distance Along Line in PostGIS

geometrypostgis

How do I create a point at a defined distance along a line?

I know we have ST_Segmentize, but it creates more than 1 points – I only need 1.

What I want is:

For each line: Create ONLY 1 point at the first or last x meter (or in a spatial reference system)

Best Answer

Thanks for the help! I've worked out a solution, so I post it here in case someone needs it. This clips 2 meter from the start and the end of each line.

select
        x.name, 
        ST_MakeLine(
                ST_Line_Interpolate_Point(x.myline,  1 - 2/st_length(st_transform(x.myline, 27700))),
                ST_Line_Interpolate_Point(x.myline, 2/st_length(st_transform(x.myline, 27700)))
                )