4

I have a geojson layer in QGIS with a list of buildings spread over a region that will be displayed on the legend, as on the image attached, by a yellow rounded dot. I am wondering if I can add an extra background icon for those that share a common feature; in this case, the century they were built.

My solution for now, as I was not working with many items, was to simply create polygons accordingly, and place them in the background; but if there are many building built in many different centuries, the manual work becomes more complicated.

Therefore, is there a way to create a legend icon that is shared by several different items (the buildings) which have a common feature (the year/century of construction)?

Example image

1 Answer 1

7

You can add a custom symbol for the legend and also use groups to get a legend as you want it:

enter image description here

  1. In the Main Properties of the legend, uncheck Auto Update and click the layer entry you want to change. Click the pen icon at the bottom Edit selected item properties

  2. Check the box Custom Symbol

  3. Add an additional symbol layer in the background of the point.

  4. Back to Custom Symbol (step 2), you can click on the trangle (down arrow) next to the custom symbol you created and click Copy Symbol. Like this, you can paste the same symbol to other legend entries.

    Creating additional symbol layers: enter image description here


Edit

In the Item Properties, you can also go to the section Spacing and under Legen Items reduce the Space between symbols to 0. Then at least visually, you get the effect you want - the groups appear with one single rectangle. Be sure to set Stroke style of the symbol in the background to No Line.

You can also add groups to the legend:

enter image description here

3
  • Yes, I have tried this method, too. If nothing else (better) comes up, I will probably end up using this. The only problem is that this will add individual additional symbols for each item in the legend, whereas what I intend to achieve is just one "grouping" icon that covers several items. In your example, it would be just one red rectangle covering layers4, layers3 and layers2 instead of three different icons.
    – Trikelians
    Commented Apr 3, 2023 at 9:46
  • You can achieve the one single grouping icon by reducing the space between symbols, see updated answer.
    – Babel
    Commented Apr 3, 2023 at 13:40
  • If nothing else comes up, I believe I will mark this answer as correct as it doesn't require any further duplication of items and it is better, after all, to strive for simplicity. Duplicating the legend layer, however, and further manipulating its items, allows for better editing. For example, in your method, adding a 45 degrees line fill -or a simple stroke, as you mention- would result problematic, as the lines in the different polygons won't coincide (or, if they do, it is after a good long tweaking), while by simply using one polygon, fine-tuning it is easier.
    – Trikelians
    Commented Apr 7, 2023 at 5:42

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.