I have classified my data into a set of classes. I want to be able to create a legend like this in the QGIS print composer:

enter image description here

Notice that the legend includes not only my category colours and labels (e.g. red, 1500 – 2000) but also a summary of the total area of all features in each category (e.g. 28.08 hectares).

How can a legend with this information be created dynamically in QGIS?

  • 1
    Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Commented Apr 17, 2017 at 12:34
  • 2
    Your question is not very clear. The image shown seems to be a diagram or annotation (part of a map legend.) used to depict the colour representation of the (polygon) area classes. Can you explain a bit more wha you want to do or achieve?
    – mapperx
    Commented Apr 17, 2017 at 16:59
  • Sounds like OP wants to know how to display the total area of each class, and have it automatically display in their legend. Commented Apr 17, 2017 at 20:50
  • I would like to create statistics according to the caption. For example, show the area where the column is greater than 2500 or <750 Commented Apr 17, 2017 at 21:11
  • @RichardLaw Yes, the area will exit according to the caption placed Commented Apr 17, 2017 at 21:14

1 Answer 1


To calculate the area of an area there is a built in the field calculator to do that. You need to create a new column if you dont already have a column for it. Then set the column type and width

enter image description here Once the column is created and the function is used to calculate the area. You can proceed to the feature styling by right clicking the layer, click properties and choose Style From the Style window, change the the styling from Simple to Graduated. choose the column with the area for classification and you can choose other settings as it fits your need.

enter image description here

By the time you go through and fiddle the various settings you should be able to get want you want. Also there are some online tutorials for Graduated styling in QGIS that can guide you through.

  • 1
    I don't think this is what OP wants. This classifies on the basis of area, but OP already has a classification, and just wants to sum the area of all features in each category, and then have that displayed in their legend. (I'm assuming a little bit.) Commented Apr 17, 2017 at 22:15
  • I assumed too that maybe thats what he is trying to achieve ;)
    – mapperx
    Commented Apr 18, 2017 at 4:33
  • @RichardLaw exactly Commented Apr 18, 2017 at 11:21
  • I think is not possible.
    – Frodo
    Commented Apr 21, 2017 at 19:51

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.