3

I am making a map of a continent on QGIS and I have marked some locations. Some of them are very close (making it difficult to read the labels) while some parts of the continent are empty.

I have therefore added an inset map. I would like to remove the labels from that area on the main map, but show them on the inset map.

While I can remove the labels from the inset map (Map 1 > Item properties > Label settings > Label blocking items), I can't seem to find the way to remove the ones on the area shown on the inset map BUT on the main map.

1 Answer 1

2

Your two maps (main and inset map) in the layout probably are at different scales. You can use this to set label visibility to scale-dependent. However, in the main map, you want some labels to show up, others not. For this, add a condition based on an attribute you create that differentiates between labels to be be shown and others not.

Let's consider the example in screenshot 1 below: main map has scale 1:2'000'000 (some labels visible, others not), the inset map (red highlighted part of the main map) 1:1'000'000 (all labels visible) - it could be any other numbers.

In the QGIS main window, select those locations that are very close/those where labels should be shown only on the inset map. You can manually select them or use an expression to select all features that have a nearest neighbor at a certain maximum distance: overlay_nearest( @layer, max_distance:=[dist]), where [dist] should be replaced by the distance in layer units (screenshot 3).

Create a new attribute called label with field calculator and set it's value to 0 for the selected ones (where labels should be hidden on the main map), to 1 for all others (where labels should always be shown).

Now in the label visibility tab, for Show label use data driven override and insert this expression: "label" = 1 OR @map_scale <2000000 - see screenshot 2. For features with attribute value "label"=1, the label will always be visible. For the others, it will only be shown on maps with a scale smaller than 2'000'000.

Screenshot 1: enter image description here

Screenshot 2: how to set data driven override; the points inside the red circle have an a value of 0 (no show) for the attribute label, all other have a value of 1: enter image description here

Screenshot 3: select by expression to select all features that have a nearest neighbor at max. 50 km (50'000 m) distance: enter image description here

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.