I have two lines (two different Shapefiles) that are part of a network and cross each other multiple times.
In some parts of my map I want one of them (let say line A) overlap the other one (B), but in other location I want the opposite, B over A.

Is there a way to do so?

I've reached a workaround that works but it is not elegant at all:

  • I put A over B
  • I copy B and put it over A
  • I cut the part of the "new B"(like me) that I don't want to be under A

QGIS 2.14 on Windows 7


No, you can't show parts of a layer above another layer and others below. That is simply contrary to the concept of the layer management / TOC used in QGIS.

All possible workarounds will mean adding an additional layer to the TOC.

However: You do not have to create additional files!

How To

  1. Create a field that holds some value to decide which lines should be above or below. this can be anything (string, int, ...) .

  2. Then, use the add vector layer / file option and add it like this:

    C:\wip\test.shp|subset=MYSPECIALATTRIBUTE = 'I am the king of the world!'
    • MYSPECIALATTRIBUTE = this is the name of the field

    • The second part is what this vaue should be so it is loaded. You didn't write what decides the layering, so I'll give examples:


This could be the three layers:

C:\wip\test.shp|subset = order = 3
C:\wip\test.shp|subset = order = 2
C:\wip\test.shp|subset = order = 0

or this:

C:\wip\test.shp|subset = surfacetype = 'Gravel'
C:\wip\test.shp|subset = surfacetype = 'Asphalt'
C:\wip\test.shp|subset = surfacetype = 'Lava'

These then show up as individual layers in the TOC and you can sort them however you want. They all access the same underlying file. Their attribute tables will be limited to their specific subset, but any change you do will be reflected on the central file as well.

Sadly, I did not find any documentation regarding the possible options of loading subsets of shapefiles. I know there are a couple others (e.g. layerid instead of subset), just can't find them.


Layers do not equal files. Layers only deal with the visual representation of data.

  • In fact, what you suggest is something similar to creating a duplicate layer (virtually, not creating two files) of one already existing in my project and then build a query in order to filter with the attribute you have previously added. But I think it doesn't help me in the case I have only two lines that cross multiple times and want them to change their position on each intersection. – Andreu Amoros Dec 1 '16 at 18:39
  • 1
    If each line is a single, continuous feature that has to be on top and on bottom alternatively, then no, I don't see how you can get that to work with standard QGIS tools. Maybe expand your question and give a more precise example of how you even decide which line should be on top at any given intersection, then we can give more suggestions. – Senshi Dec 2 '16 at 9:39

It seems symbol levels cannot be subject to rules.
However, you could still try this, depending on the geometrical configuration of your data:

  • Find a X (Xlim) east or west (or Ylim north or south) of which you want the
    difference to take effect;
  • Use rule-based symbology;
  • Create four rules, the first one for showing line A, the second for line B, the third for line B, the fourth for line A;

  • The rules would follow this scheme: :

    "line"='A' AND x(start_point(geometry( $currentfeature)))- Xlim <0  
    "line"='B' AND x(start_point(geometry( $currentfeature)))- Xlim <0  
    "line"='B' AND x(start_point(geometry( $currentfeature)))- Xlim >0  
    "line"='A' AND x(start_point(geometry( $currentfeature)))- Xlim >0

This of course would not work if you have only two continuous lines. It is probably not possible in this case, since symbology operates per feature.

  • 1
    This can be a great alternative. Trickier to implement, but doesn't require additional layers and additional fields (if you don't have a distinct field already). In the end, it all depends on the use case. – Senshi Dec 1 '16 at 12:10
  • Thanks for your proposition. In fact it is a great alternative, but with two continuous lines, it doesn't work. I have to create a duplicate and "cut" it or split the lines into segments in order to play with each one. – Andreu Amoros Dec 1 '16 at 18:42

Your Answer

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

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