3

I have some route data with several routes which follow the same path for a distance. I would like to display the data showing thicker polylines where routes overlap, the more that overlap the thicker the line.

Is this possible using QGIS?

0

2 Answers 2

10

I assume your routes is one layer.

You can create a virtual layer with the code:

with cte as (
Select st_intersection(a.geometry, b.geometry) geom --3: Return the intersecting geometry
from "routes" a
join "routes" b
on st_intersects(a.geometry, b.geometry) --1: If two lines intersect
where a.id<>b.id) --2: And the id is not the same

select count(*) n_overlaps, geom --4: From the above query, count number of intersecting lines
from cte
group by geom --5: With the same geometry

Replace "routes" with the name of your layer, and id with the name of your unique id field (which you need to create if you dont have one).

The output layer will have an attribute showing the number of overlapping lines. Use this to symbolize:

enter image description here

8
  1. Explode lines
  2. Create a new attribute with field calculator and this expression: array_length(overlay_intersects( @layer, $id))
  3. Set stroke width to data driven override and use the attribute from step 2 as input.

Lines are set in different colors based on the initial line's unique id to better discern how different lines overlap: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.