Creating lines from lonely nodes in a linestring table to closest point on another li

المشرف العام

Administrator
طاقم الإدارة
I want to segmentate a country (denmmark) by using barriers such as larger roads, railroads and the border/ coastline as the delimiting lines of the polygonise function in QGIS. But as most roads and railroads ends well before hitting the coastline I get some very long polygons along the coast.

I would like to split these long polygons when using the polygonise function by extending road segments close to the border out to the coast. But I only want to select start and end nodes of segments that don't share more than one start and end node with the road network. I've written some SQL for PostGIS that is supposed to solve the problem by utilising that the segments share geometry in the start and end nodes, unless they fulfill my requirements:

create table snaplines3 as select st_makeline(st_endpoint(a.geom),st_closestpoint(b.geom,st_endpoint(a.geom))) from vej_jernbane_multi_to_single a,dk_graense b where st_dwithin(st_endpoint(a.geom),b.geom,50) and st_touches(a.geom,b.geom) is false and st_asbinary(st_endpoint(a.geom))!=st_asbinary(st_startpoint(a.geom)) union select st_makeline(st_startpoint(a.geom),st_closestpoint(b.geom,st_startpoint(a.geom))) from vej_jernbane_multi_to_single a,dk_graense b where st_dwithin(st_startpoint(a.geom),b.geom,50) and st_touches(a.geom,b.geom) is false and st_asbinary(st_endpoint(a.geom))!=st_asbinary(st_startpoint(a.geom)) Unfurtunately my code doesn't work as the part st_asbinary(st_endpoint(a.geom))!=st_asbinary(st_startpoint(a.geom)) doesn't seem to do anything.

Does anybody have an idea as to why it doesn't work and alternatively another solution.



أكثر...
 
أعلى