5

Is there a setting to turn off labels within a polygon in an Atlas?

In the example below I don't want labels to show in the grey inset area.

enter image description here

I have tried the new clipping functionality

enter image description here

All the label data to be clipped is in the chosen file DSC_Point_Symbology

The AOI (grey area) is defined as follows so that any area in a map frame that's not the current AOI is covered.

enter image description here

It's only the labels in the grey area that should not be shown, the labels from the same data should be shown in the other areas. The symbol should be shown in all areas.

I am using QGIS 3.22

I have checked Removing labels from area that is also shown on inset map using QGIS and as zoom level and the input features are relatively dynamic having to process all the labels separately seems inefficient.

Can a polygon from the map be selected in the Label Settings -> Placement -> Label Blocking items?

enter image description here

UPDATE as per @Pieter's response.

enter image description here

The labels don't show now anywhere in the map (blue highlight compared to previous screengrab). They should only be removed from the grey area.


Example and notes

Please download https://drive.google.com/file/d/1hVNCXfY8Zgvag1NFB3zjNoyYk7OSwZib/view?usp=sharing

This is just a quick example with some training data, packed using QPackage.

See map 7 and 12. 12 is a small area of map 7 but as the features are complex in it, I want it covered and the labels under it to not show. The labels should show in the rest of the map.

So in the zoomed out map (7) all the labels (yellow highlight) in the grey section should not show but they must be visible in the rest of the map.

enter image description here

On Inset 1 (map 13), the grey border should not be shown. enter image description here

I'd say we need to forget about the atlas initially and see if labels can be clipped / masked by a polygon?

2
  • did you try to set that layer as blocking (layerproperties > labels > Blocking)
    – PieterB
    Nov 22 '21 at 11:59
  • Yes, and the weight is maxed on the AOI and less on the objects within it. It renders ok in the map view but in the layout, it includes all the labels within the AOI.
    – GeorgeC
    Nov 22 '21 at 12:17
5

You could define an expression-based value on the labelfields.

if(intersects($geometry, @atlas_geometry), '', "labelfield")

This expression gives no label if it intersects the atlas_geometry. If not, a label will appear

enter image description here

9
  • The issue is the grey (inset) area is also part of the atlas. Is it possible to do this in a way that it's if the geometry doesn't intersect the geometry of the inset AOI it doesn't show?
    – GeorgeC
    Nov 22 '21 at 12:26
  • so the grey area is not the atlas feature?
    – PieterB
    Nov 22 '21 at 12:28
  • It is but it's shown in the next page. So we have the area map at 1:15k, and then the zoomed map at 1:5k. As the labels in the zoomed areas are too close together in the 1:15k view we want them covered in the 1:15k view with a note to see another page for this area. I will update the question with an example.
    – GeorgeC
    Nov 22 '21 at 12:33
  • so @atlas_geometry just needs to be a reference to a feature in the AOI inset polygon. So if we know feature id 3,8,11 are insets can we do something like if(intersects($geometry, ... geometry of AOI.PageID in (3,8,11) ... ), '',"Labelfield") If so how is this written?
    – GeorgeC
    Nov 22 '21 at 12:44
  • if you set your insets as the reference for your atlas generation, then it renders automaticly without labels with that expression
    – PieterB
    Nov 22 '21 at 12:46
2

Based on my understanding, you have Atlas layer that contain polygon. Some are made to be set the view on a regional scale and some are made to get a view at a local scale. These polygons can cross one another.

In your example, you want to show a label that is in your map view, but that doesn't cross other polygons existing in your atlas layer.

The solution would be to set your atlas layer to not render the current polygon used for atlas. You will get the same result as you show in your screenshot. Then you set the label in your atlas layer to be blocking. Only the feature not used as atlas will block the label to be created.

The problem will still exist for your city map atlas feature as the polygon for regional map will be also visible and will block your label. To solve this, you could add a rule of visibility based on scale to have no atlas feature shown at the smallest scale.

3
  • I have added an example project that I quickly did and some clarifying notes.
    – GeorgeC
    Nov 22 '21 at 22:26
  • I found that there was 'something' in the label layer that prevented the blocking label from working. When I tried it without a complex label it worked and then I had to rebuild the rule-based labelling again.
    – GeorgeC
    Nov 27 '21 at 9:42
  • The issue was that I had "Show all labels for this layer" turned on. The way to fix it was to keep this off and use the "Always show" override to if ($id != @atlas_featureid,0,1) and the AOI with blocking had a rule based symbol where the polygon with a 100% transparent polygon had $id in (4,8) where 4 and 8 were the id's of the polygon that had an AOI inside it.
    – GeorgeC
    Nov 30 '21 at 21:26

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.