Creating point at defined distance along line in PostGIS?
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)))
)
If I understand you correctly, my suggestion is as follows: run the script
create table your_new_tbl_name as
select ST_EndPoint(ST_Intersection(geom,
ST_Buffer((St_StartPoint(geom)),0.001))) as geom
from your_source_tbl_name
- Please note that 0,001 = 111,12 m;
- In this construction, I use a buffer that is built from the first point, with the specified distance, then define a common cut line and select the end point...
- You can do the same on the endpoint using ST_EndPoint...
Note: the line should not be curve...
if you want to set the required distance in meters, run this query, for example, with a distance of 50 m:
create table your_new_tbl_name as
select ST_EndPoint((ST_Intersection((geom)::geography,
(ST_Buffer((St_StartPoint(geom)::geography),50))))::geometry) as geom
from your_source_tbl_name
This method is called a compass-meter.
my source data is in the geographic coordinate system, with respect... (:-)