2

Background:

As part of a route selection process I have multiple route options which often share segments. I need to keep the underlying data correct while displaying all routes in a way that they don't obscure each other.

Desired Result:

I would like to do this by offsetting the different routes, but only where they share segments with other routes, something like this (taken from another SE question): enter image description here

What I've Tried:

Giving each route an offset in its symbology works OK when the routes are overlapping but this method breaks down when they are not because the route is now being shown in the wrong place.

I tried following this answer to a similar question: https://gis.stackexchange.com/a/141627/98170 but the result is the same as manually applying offsets as above.

This question and answer look great: Display overlapping polyline segments as multiple lines with offsets? but it is for Leaflet not QGIS.

This answer https://gis.stackexchange.com/a/239370/98170 is almost there but I don't want it to pinch back in at each vertex and I don't know how it would work when the lines are no longer overlapping.

I've tried messing around in the geometry generator but to no avail also.

Any help with this would be much appreicated.

  • You could create a new line layer, divided into segments, where each segment has one field for each route in the original layer, and yes or no for the value. Then use a rule-based style for the new layer. Eg, one rule would have this filter: "route1 = 'yes' and "route2" = 'yes' and "route3" = 'no', with a style that has a line for route 1 and a line for route 2, with appropriate offsets. – csk Sep 3 at 19:06
  • @csk The problem is that the number of overlaps can change so that at one section route 3 would need to be offset but 1 but at another section it may need to be offset by 3 – TeddyTedTed Sep 4 at 8:05
  • That's what I meant by "divided into segments." The section where that route needs to be offset by 1 should be a separate segment from the section where it needs to be offset by 3. Make sure each route has a unique "route name" or "route number" attribute so you can make their color depend on that attribute. – csk Sep 4 at 16:52
  • I found this method to get a count of how many route overlap each segment: gis.stackexchange.com/a/290883/81764 – csk Sep 4 at 18:25
  • Thanks @csk, I think that would be the best method for a smaller number of routes, however at the moment I can have any combination of 16 routes overlapping in different sections so that may be too time consuming. Great idea about having a single line which lists each route it is included in though. Thank you – TeddyTedTed Sep 6 at 10:32

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.