8

I have two layers in my QGIS Project (QGIS 3.4.8). One in the foreground, which contains surfaces, and one in the background, which contains a point with labels, see image below:

enter image description here

The problem is that the labels from the second layer are always in the foreground:

enter image description here

I would like the second layer's label to be displayed in the background, just like the layer itself.

Is this possible in QGIS?

Desired target result (image edited with MS Paint):

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • 7
    "Why on earth would you wanna do that?!" cries the cartographer. – Erik Nov 17 '20 at 09:46
  • 1
    Don't worry. I have a more complicated project where it makes sense. Here I am just asking if it works in QGIS. – Dawid DLLISt Nov 17 '20 at 09:50
  • Have a look at this: https://gis.stackexchange.com/questions/230671/symbols-above-labels-in-map-qgis/230684 – Erik Nov 17 '20 at 09:56
  • 1
    And this: https://gis.stackexchange.com/questions/175697/avoiding-labeling-features-if-overlapped-by-another-layer-in-qgis – Erik Nov 17 '20 at 09:56

2 Answers2

9

Using QGIS 3.16.0

Assuming your labels are stored in "name" field, go to Layer Properties > Labels and set the labeling expression as below:

if(overlay_disjoint('area'), "name", "")

enter image description here

More information about overlay_disjoint() function, please find in Changelog for QGIS 3.16 and QGIS Docs » List of functions » overlay_disjoint.

Taras
  • 32,823
  • 4
  • 66
  • 137
Kazuhito
  • 30,746
  • 5
  • 69
  • 149
  • Would probably be possible using older QGIS versions with either overlaps or disjoint and some aggregate-wizardry. – Erik Nov 17 '20 at 10:44
2

I have a similar question, and I find a solution. I don't know if this can help:

  • find the label style of the polygon feature.
  • set it as "blocking" enter image description here
孟泽楷
  • 21
  • 2