6

I have the following attribute. I would like QGIS to prioritise only the maximum value from field1 while labelling. In other words, on the figure 2 (zoomed out version of figure 1), I would like to label 9.9, 8 and 5.4 rather than how QGIS priortised the lower value in QGIS 3.16.

atrribute

figure 1

figure 2

1 Answer 1

5

In the "Placement" tab of the label setting there is a "priority" setting for label. by using data defined override you can give higher priority to label with higher value simply by using your field as expression (so the label "9.9" will get a 9.9 priority and will get render rather than label with lower priority/value)

enter image description here

EDIT : To reverse the order you just need to multiply by minus 1.But you may also use an expression to set any order you may find useful.

For exemple if you want to get the middle value prioritized you may create an expression that reclass the value by attributing an higher priority to the middle value :

CASE WHEN  "field1" >2 and  "field1" <5 THEN 10 ELSE 0 END

This expression will give the highest priority (10) to value between 2 and 5 and the lowest (0) to other value. In your case it will display 3 and 4.1 before the other value. This way of reclassifying is also the way to go if you need to prioritize with a non numeric field

3
  • that was useful. What if I would like to do other way around prioritise 3, 4.1 etc ., over 9 (to prioritise the lowest value first)?
    – Raj
    Commented Feb 1, 2022 at 17:41
  • "field1"*-1 solves my above comment
    – Raj
    Commented Feb 1, 2022 at 17:44
  • 1
    See edited answer for more detail on the ordering
    – J.R
    Commented Feb 2, 2022 at 11:25

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.