5

I have a polygon layer with attributes text_x and text_y which I use for label placement with data defined override.

In this screeshot the red dots indicate text_x, text_y coordinates and as can bee seen, QGIS tries to automatically place labels somewhere inside the polygon in cases where the polygons are not completely inside the map canvas and text_x, text_y is outside the map canvas too (NO27, NO10, NO11, NO12):

enter image description here

Little zooming shows the expected correct placement for these lables:

enter image description here

This behavior is really annoying, therefore my question:

Is there a way to make QGIS placing the labels strictly at the given coordinates (means not rendering labels or only the part of the label inside the map canvas when text_x, text_y is outside the map) and in no case anywhere else?

My placement settings that might affect the behaviour are the following:

enter image description here

2
  • 1
    You may try to use the labeling geometry generator to create a point with your text_x and text_y as input, I think it shouldn't put label if the generated point fall outside canvas
    – J.R
    Commented Feb 10, 2022 at 14:12
  • This works even with data defined override activated (obviously geometry generator is mightier than data defined override placement). As a side effect with data defined override kept active moving labels with the mouse still works! Considered this as an answer? Commented Feb 10, 2022 at 14:47

1 Answer 1

5

I found the responsible setting (as far as I see at this point) more or less accidentally but not in the Placement settings but under Rendering:

v

Unchecking the option Show all labels for this layer (including colliding labels) has the desired effect (see NO11 and NO15, even cut at the canvas border!):

enter image description here

1
  • 2
    Just FYI. When exporting the map from the print composer there is an option for the map if you want the cut-off labels included when it's exported or not. Commented Feb 10, 2022 at 15:35

Your Answer

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

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