Thursday, 8 November 2018

Rule based coloured background for labeling in QGIS


I am a newbie working on QGIS 3.6 / Windows 10. I need to label a polygon layer which is categorised by colour. (pls refer to attached pic as a graphical reference)



enter image description here


The labels need to have a background which is also categorised by colour (red, orange, yellow and white) according to values in the attribute table of the shapefile.


My understanding is that the map as pictured has been created with an older version of ArcView...


Is it even possible to achieve something similar in QGIS?



Answer



In the attribute table of your polygon, you will have a field which dictates the polygon colour, another which dictates the label colour, and another which dictates the label text. I've made a quick example below.


enter image description here


You can set the layer symbology to 'Categorized' based on your polygon colour field.


enter image description here


And set you labels to 'Rule-based labelling'. You'll need to set rules as required for your dataset, my example rules follow the format "Label colour" = 'yellow' etc. enter image description here Example output below.



enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...