Search code examples
qgis

QGIS How can I get city labels to render largest cities first?


When I plot cities in QGIS, it chooses which to plot and which to leave out. This layer also has the population. Is it possible to make QGIS plot the larger cities first using population as its guide?

SE Nebraska


Solution

  • In the labels tab of the layer styling panel you can set the priority of a label to be an expression (the yellow box below):

    enter image description here

    In this case I have set the "value" to be this expression:

    CASE 
        WHEN  "type"  =  'City'  THEN 10 
        WHEN  "type"  =  'Town'  THEN 9
        ELSE 5
    END
    

    So that labels with a type "City" are drawn before "Town" which are before all the others. To make a priority based on population you could use something like:

    log10("Population") 
    

    As priority is expecting a value between 0 and 10.0.