I would like to join linestrings which are connected to each other. The preferred output is a longer linestring based on all joined single linestings! The table that holds my single linestrings is called “traffic_roads_temp”. Each linestring has the attribute ref. Ref describes in my table the affiliation to a certain motorway or road.

As you can see in the picture below the motorway A 2 and A 7 could be easily joined by using something like this:

select ref, st_linemerge(st_collect(way)) from traffic_roads_temp group by ref

One of the problem is, that the output seems to be a multilinestring and not a linestring.

The main problem is the motorway A 39. It consists out of two separated road segments. Therefor I would like to generate two linestrings of the A 39 --> A 39.1 and A 39.2 All other motorways could be stored in one linestring per motorway.

Maybe somebody of the experts in this forum could help me to solve this problem(s):

  1. Generate long linestrings from single smaller linestring. (No multilinestring)

  2. I case of the motorway A 39 which consists out of two spread road parts – I would like to generate something like a series: A 39.1 and A 39.2


enter image description here

  • It seems that you need only a query that generates the start and end point and all segments that contatin the route, perhaps give it an alternate name to be used for the thru route. I don't know postgis syntax but say (linestring = start xy and name = x or name = b and ref = aa or ref = ab and linestring = end xy = (') and string = (0 0, 1 1, 2 1, 2 2)') = linestring " ". That said maybe you could select your string in a gui and then export or decompose the selection to get working values to reverse engineer your solution. – lewis Feb 22 '13 at 20:03

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.