4

I have this situation:

enter image description here

All layers are filtered to the region except the layer "bahnstrecken" who is missing that attribute. Instead I use the polygon "bundeslaender" (inverted polygon style) to overwrite features of the layer "bahnstrecken" (black lines) outside of the shown region. This works perfect. But as soon I want to label the "bahnstrecken" (which I did with orange numbers), the labels show up outside the region. I only want to show the labels WITHIN the region.

I know the problem can be solved by just clipping the "bahnstrecken"-layer to the region. But I am just curious: Is there any other way how I can solve the problem, without manipulating the data?

8
  • 1
    You may want to check the Mask plugin that claim to be able to do that...
    – J.R
    Sep 10, 2020 at 13:29
  • Great, that works almost perfect. Just a few labels near the border (but still outside of the region) are shown. Big improvement. But is there any other solution without downloading a plugin? Sep 10, 2020 at 13:36
  • 4
    You could try to use rule based labelling with an expression using "intersects" to filter outside labels (see gis.stackexchange.com/questions/326892/… for a somewhat related exemple of using intersects)
    – J.R
    Sep 10, 2020 at 13:48
  • 2
    I love that! I used that expression for rulebased labeling and it works: intersects ( $geometry, geometry(get_feature('bundeslaender','name','Thüringen'))). But still, a few numbers near the border but outside the region-polygon appear. This is understandable because some line segments of "bahnstrecken" are both within and outside of the region polygon. I tried the same expression with WITHIN instead of INTERSECTS and it labels only the line features that are fully within the polygon. Great! Sep 10, 2020 at 14:26
  • 2
    nice to see you make it work, you should put that as an answer so other people with the same problem will find it
    – J.R
    Sep 10, 2020 at 15:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.