Give a table of linestrings (roads)

ogc_fid, wkb_geometry

And a road with ogc_fid = X

In postgis how could I construct a linestring that is of length Y metres made up of roads starting from road X? I do not care which direction the line expands out of. It is important that the algorithm goes both ways to prevent dead ends.

My starter code was this:-

SELECT ST_LineMerge(ST_Collect(R.wkb_geometry)) FROM ROADS R
WHERE ST_Touches(R.wkb_geomtry, (SELECT wkb_geometry FROM ROADS where ogc_fid = X))

But I am not on the right track as this returns a MultiLineString which means the LineMerge has not worked?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.