2

I have two layers, one with points that I have set a label on and another with polygons which I would like to use to block the labeling of the points. According to this old answer to Avoiding labeling features if overlapped by another layer in QGIS? I could use the blocking of labeling option of the polygon layer, but this only works partially.

With "No labels":

No labels

With "Blocking":

Blocking

Is this a bug or have I understood the option of "Blocking" wrong? (What other option than remove the points under the polygon do I have?)

5

If you want to block completely (hide) the labels under the polygon, you can use the following formula under point label tab -> Render -> Show label -> Edit, and write the following expression:

enter image description here

case
when intersection( $geometry, geometry(get_feature( 'PolyBlock', 'id',0))) then 0
else 1
end

Where 'PolyBlock' is the name of the polygon layer in the layer tree, and 'id' equal 0 is the id field which has the value 0 or the value exists for the target polygon, which you want to use it to hide the labels of the points.

Here is the results

enter image description here

| improve this answer | |

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.