I have a network in QGIS illustrated as Step 0 in the following figure:

enter image description here

In the actual network, these three links (red, blue and green) are geometrically duplicated. (I slightly shifted them to show the network configuration)

My goal is to store the number of duplicated links so that I can illustrate it in bandwidth map as illustrated in Step 2.

Currently I exploded these three links in QGIS (Step 1) to cut links at intersections/crossings of each link. However, I cannot find the way to count the number of duplicated links.

Do you have any suggestions to reach the desired result? I tried to find such tool in processing toolbox but most of them can be used only for removing duplicated links without counting (i.e., Delete duplicated geometries).

I believe that it can be reached using Python code, but unfortunatelly, I do not have enough knowledge to deal with spatial data with Python.

I am using QGIS version 3.16.14.

1 Answer 1


You can use this simple expression to count lines in the same direction:


"geometry equals" respects the vertices order. So in case one line is drawn in the opposite direction, it is not equal and therefore not counted.

To also count lines in the opposite direction you can use "geometry contains":


For QGIS versions below 3.16 you can use aggregate() instead of the overlay functions like this:

  • Thank you! I will learn more aboutn expressions in QGIS, it seems to be working in my actual network. After the calculation, I simply removed all duplicated links and could draw a bandwidth map based on the result. As I am not sure whether all duplicated links have the same vertices order, it is appreciated if you or someone could provide another solution for that.
    – HSJ
    Commented Jan 30, 2022 at 12:45

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.