0

I have a point layer in my QGIS project that displays a big number of addresses of a number of cities. In the map for each feature, I would like to display two values: The housenumber and the number of units currently residing in that address. Therefore, I have two fields: Housenumber and Units.

I want the housenumber to be displayed above the point on the map in blue and the number of units below in red, similar to this:

Map with housenumbers (blue) and number of units (red)

Currently, I have solved this issue by the way that is explained in this thread.

That is a pretty good solution, but unfortunately using those text diagrams does not seem to allow using Symbology. Now, I would like to use a rule-based symbology, to be able to create copies of the layer that each display only the addresses for one city. Normally, I would just use the expression "City" = '...' and assign my symbology to it, and everything would be perfect. But this does not seem to work in combination with the text diagrams, because no matter what rule I put in the symbology, it still displays me all features.

The only solution I could think of was creating two copies of the layer per city, and configure the symbology to once display the housenumbers and once the units, but I was wondering whether there is a more elegant way?

Thanks a lot!

1 Answer 1

3

You can use Rule based labeling instead of labeling two layers, although the process will be almost same.

Here is the workflow of how to do that:

  • Go to layer symbology → Labeling → Rule-based Labeling
  • Click on green plus at the bottom left corner to add the first label layer
  • Under the Value, select the the first field (housenumber) in your case. In my example, I am choosing POP_MAX, and select the font color you like.

enter image description here

  • Go to Placement → Select Offset from point → Select Top middle

enter image description here

  • Go to Rendering → Select Show all labels for this layer (including colliding labels)
  • Select Show label and put the following expression

    "City" = 'Value'
    

enter image description here

Repeat the above process for the second label layer to select the Unit field and give it the color you like. Under placement select bottom middle, and under rendering show all labels and put the above expression again for the city you want.

In my example I am using city layer from NaturalEarth and I showed only the POP_MAX and POP_MIN in France:

enter image description here

Here is a zoomed in version to the points:

enter image description here

1
  • Amazing, I am gonna check this solution out! Thanks a lot!
    – Kai
    Mar 5, 2020 at 20:40

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.