Same question, updated in 2021: Using QGIS 3.16, is it possible to "expand" the label blocking footprint of a point feature to match it's icon size?

For example, I'm USGS "badge" symbols for points like campgrounds, and in some cases, like when I have a campground on a small lake, the lake labels will "over-post" the icon. In the sample image below, I'd like the extent of the campground icon to "block" the blue "Poia Lake" label from over-posting it.

Is it possible to give the "campground" point or symbol a way to act as a "label blocking area" that matches the size of the icon, forcing QGIS to either hide the lake label or move it to an uncluttered location?

Label overlapping icon

CLARIFICATION: Looking at the label placement options, I'm imagining expanding feature obstacle area to "match" (or at least be near the size of) the symbol in points vs on-the-ground size, which obviously changes with map scale.

enter image description here


3 Answers 3


The trick is to use Geometry generator to create a geometry where label placement is allowed. You are free to define the geometry in a way to fit your needs. Adapt it as you want:

  1. Go to label settings, placement tab and activate Geometry generator.

  2. Use QGIS expressions to define an area (polygon) where placement is allowed: a buffer around the lake, but excluding another (smaller) buffer around the campsite. With the following expression (adapting layernames and buffer sizes), you get an appropriate "donut"-style polygon with a hole where label placement is not allowed (cf. second screenshot).

  3. Inside this polygon, still with the same expression, get the pole of inaccessibility as anchor point for the label:

pole_of_inaccessibility( difference (
    buffer ($geometry, 1000),
    buffer (overlay_nearest('campsite', $geometry)[0], 400)

Label before setting geomtry generator:

enter image description here

Label after setting geometry generator for label placement. For visualization purpose only I created the buffer with a symbol layer based on the above expression:

enter image description here

There are different settings possible together with Geometry generator that makes it possible to control in detail where the label appears. A simpler version is to just define the "forbidden" area (buffer around campsite, red hached area in the next screenshot) and set Placement mode to Outside Polygons:

enter image description here

Still another option is to create a small buffer around the boundary of the lake and substract from this a boundary around the campsite:

    buffer (boundary ($geometry), 4),  
    buffer (overlay_nearest('campsite', $geometry)[0], 70)

Red here defines the polygon that defines the area for label placement: enter image description here

  • Thanks for these explanations, they are really great. I'll try using them. Jan 5, 2022 at 2:15
  • However, it's not quite what I intended to ask... do you have any suggestions for creating a blocking area for the campsite itself? Based on looking at your suggestions here, I'm imagining using the geometry generator to buffer the point to the size of the icon, so that the "point areas" can block over-labeling across multiple polygon and line layers. If you have any ideas, please post a second answer for point-based expansion blocking Jan 5, 2022 at 2:18
  • I'm not sure what you mean by "blocking area for the campsite": creating a buffer around the campsite (point feature) that is subtracted (using difference) from the allowed area effectively blocks labels to be placed there. So I'm not sure what exactly you try?
    – Babel
    Jan 5, 2022 at 8:47

For precise placement of a label, a great new feature introduced in QGIS 3.22 are annotations (see here for documentation). Use the icon Create Text at point to place an individual label at any place you wish.

The advantage is that it does not move and has a fixed size, so perfect for intutitve labeling, but still with full control over all aspects of the labels that automatic labeling does not offer - or only at the cost of extremey complex rules that often result in an "automation trap", realizing with extremely sophisticated technologies what could be faster and easier done manually.

From the documentation linked before:

While annotations are created in this free-form way, every annotation item is still completely geo-referenced and tied to a particular geographic location. Moving your map, changing the scale or changing projection won’t cause your annotations to jump around the map. Rather, they’ll be locked in place to the location you’ve drawn them. Unlike features in a traditional vector layer, it’s easy to interactively style annotation items on an item-by-item basis. (This is what makes them a great tool to help quickly create beautiful maps!).

Activate the Annotations Toolbar, select the icon Create Text at Point an click on the map, add your text and style it. With the Modify Annotations icon clicked, click on the text annotation to select it - then you can freely move it using the arrow keys (together with the SHIFT key pressed, you get faster movement).

This comes very close to an intuitive labeling for individual situations as it an be done in graphic software - a cartographic perfect labelling for high quality maps - I would argue - is still manual work. This becomes a lot easier with these annotation tools.

enter image description here

  • Another awesome answer, and for individual maps, annotation is for sure the way to go. I love your descriptor of "automation trap", which is what I am probably in. But when you generate a lot of atlas-based maps at a variety of scales, annotation has it's own drawbacks Jan 6, 2022 at 4:57

The solution you're probably looking for is activating the Blocking labeling on the campsite layer:

[It] allows to set a layer as just an obstacle for other layer’s labels without rendering any labels of its own.

enter image description here

Individually define the Obstacle weight on both layers to define which one should have priority and to what degree: the label (setting high priority on the lake layer) or the campsite (setting high priority on the campsite layer / reducing priority on the lake layer).

Before: No label activated on the the campsite layer; the lake layer is labeled and covers the campsite: enter image description here

After: with label style Blocking activated on the campsite layer, it prevents labels from the lake layer to cover campsite features: enter image description here

  • Yep, 100% agree, this is a great way of doing this for features that don't have labels themselves. However, if you want to label the point feature as well (which is what I am trying to do), this won't work. That's where my original question of trying to "block" the area icon comes into play. Jan 6, 2022 at 4:52
  • 1
    Duplicate the campsite layer: once with labels+symbolization, once with blocking and set the obstacle weight in a way that only labels from lake are effectively blocked. I guess combining my first solution with this one here allows for automatic labeling in a way you're looking for.
    – Babel
    Jan 6, 2022 at 6:56

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.