1

I am editing the polygon layer by adding new polygons and moving them to new locations. When I place a polygon in a new location I would like any labels from the two point shapefiles that happen to be under the polygon to disappear, while the labels of the points not covered by any polygons remain. This is purely for visual reasons as I am trying to cover all the points with polygons and eliminating the labels beneath existing polygons would make it more obvious which points still need to be covered. Is this possible in QGIS 3.6.1?

The closest thing I have been able to find on SE or anywhere else is the 'discourage labels from covering feature' option (Layer Properties -> Labels -> Rendering -> Obstacles) but even when I moved the slider all the way to the high weight side it didn't even move the labels, let alone make them disappear.

2

You could use refFunctions plugin together with the expression geomwithin('polygon','$geometry') is NULL for that:

enter image description here

Replace 'polygon' with the name of your polygonlayer. Just set the expression as filter and lables of points covered by the polygon will no longer be shown.

  • This seems like exactly what I am looking for but for some reason it isn't working for me. The expression you provided (modified with my polygon layer name) is not throwing any errors but it is not making any labels disappear for me. As far as I can tell, nothing happens when I apply it. When I test it, it always says the filter returns 100 features (which is the number of points with labels), even when some of the points are not within the boundary of any polygons. Any ideas? – ia200 Jun 6 at 21:16
  • Cant really tell.. are both layers in the same crs? – MrXsquared Jun 6 at 21:31
  • Ah that's probably the issue. I'll get them into the same CRS and then provide an update tomorrow. I'll mark your answer as the solving the issue because I'm pretty sure this will do exactly what I was asking for. – ia200 Jun 6 at 23:41
  • 1
    Just to confirm, this did exactly what I was asking for once I got both layers into the same CRS. Thanks! – ia200 Jun 7 at 13:22
1

Frame Challenge: This is not a good method for what you're trying to achieve. Labels are always rendered on top of all the features on the map. So you'll never be able cover up the labels with a polygon.

Instead, try replacing the labels with a font marker symbol. When you put a polygon on top of a point, all parts of the point symbol that fall underneath that polygon will be hidden. See illustrations below.

Replace your labels:

enter image description here

with a font marker symbol layer:

enter image description here enter image description here

enter image description here

Now when you draw a polygon on top of the points, it hides the font marker:

enter image description here

  • Thanks for this clever work around. Since my polygons have an empty fill pattern this doesn't work in this particular situation but now that I know this option exists, it could be very useful in the future! – ia200 Jun 6 at 21:18

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.