Saturday 27 October 2018

How to display multiple attributes in a QGIS Composer legend?



I have a polygon layer which has a number attribute and a text attribute. When I make a legend in the composer, it automatically chooses the number to display while I would like to have both the number and the text.


How do I display two attributes in a legend? If not possible, how do I select which attribute is displayed in the legend?


Sample of the attribute table


I am not looking to have a multi-attribute label in the main window, I wish to have a multi-attribute label in the legend of the composer, or choose which attribute is displayed in the legend.


QGIS 2.8 Win8 64 bit.



Answer



You could simply concatenate the three classification fields in the layer's properties.


 "Unit_Num"  || ' ' ||  "Age"  || ' ' ||  "Name" 

Layer properties



Then it will also appear in the legend in the Print composer:


Legend in Print composer


Unfortunately, the concatenated text will also appear in the main window.


Edit: The legend is derived from your classification, but you can of course label your features with another field:


Labeling


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...