4

I'm new to QGIS and I am doing some demographic analysis of Ethiopia. I have a vector map with each of the country's administrative zones:

Within the attribute table, I have data for religious demographics in each zone.

What I would like to do is have color swatches appear within each polygon (five different colors each representing the different religion), based on the proportion of the population that follows that religion. So, if one zone was 50% Protestant and 50% Muslim, that polygon would have equal amounts of red and green swatches.

Similarly, if one zone was 30% orthodox, 50% muslim and 20% protestant, there would be three color swatches present, with the color representing muslim being predominant.

Here is also a screenshot of my attribute table, as requested:

The info I'm interested in displaying is to the right: the percentage of a zone's population that follows a certain religion. For many of the areas, it is overwhelmingly a single religion, but a good amount show a lot of variation over two to three different religions.

enter image description here

enter image description here

3
  • Can you show us a sample of your attribute table?
    – Matt
    Nov 2, 2016 at 14:53
  • 2
    The Diagrams tab in the Layer Properties window is what you're looking for, but as @Matt implied, its use will depend on your attributes.
    – ArMoraer
    Nov 2, 2016 at 15:28
  • I posted a picture of the attributes. Thanks for the help!
    – D maps
    Nov 2, 2016 at 17:22

2 Answers 2

3

If you actually wanted to proportionally colour the polygons themselves rather than including diagrams you could do something involving layered gradient fills using the underlying data to determine the extent and offset of the fills.

It isn't neat but it does colour the actual polygons rather than overlaying something on top.

Attribute Data:

You will need the data in your attribute table to be in decimal percentage format:

Att01 - 0.3 (representing 30%) Att02 - 0.4 (representing 40%) Att03 - 0.3 (representing 30%)

They need to add up to 1 (i.e. 100%)

EDIT - you seem to have this anyway looking at your data table

Layer Styling:

  • Open the properties dialogue of your layer and navigate to the Style tab
  • Select a Single Symbol Style Change the symbol type to 'gradient fill'

enter image description here

  • Select 'colour ramp' and open the edit properties of the colour ramp
  • Set the primary colour to something and the secondary colour to transparent
  • Set the Type to discrete (next to the second colour)
  • Stretch the middle stop all the way over to the right hand side
  • Click ok

enter image description here

  • Scroll down the properties to the section where you can set the Reference Points for the gradient. The reference points control where the gradient begins and ends. Reference point 01 controls where it begins and reference point 02 where it ends. We can use this to offset the gradient and control its width based on the proportional data in the attribute table.
  • The default values are RF01 0.50,0.00 and RF02 0.50,1.00 - leave these alone
  • For the first gradient we want it to start from the beginning and then end representing the proportion of the first attribute
  • leave reference point 01 alone and click the icon to the right of the reference point 2 y -> select field type -> your first proportional attribute (mine is called Att01 in the image below)
  • Set the rotation value to 90 is you want the proportional stripes to be vertical as in the example

enter image description here

  • Add another symbol layer by repeating the instructions above - make the gradient a different colour
  • To offset this 'stripe' set reference point 1 x to be equal to the value of attribute 01 (so that it starts from the end of the first stripe) and then set reference point 2 y to be equal to an expression of Attribute 01 + Attribute 02 (so that it ends proportionally to attribute 02.

EDIT - You might need to specify a small value for any fields that are actually 0, for example 0.001 as otherwise the expressions fall over. You could do this in the attribute table or through an IF statement in the expressions.

  • Add a third symbol layer and repeat the first two parts - in this case reference point 1 x will be an expression of Attribute 01 + Attribute 02 and reference point 2 y will be Attribute 01 + Attribute 02 + Attribute 03
  • Repeat as required to add other classes

enter image description here

  • The final output looks like this:

enter image description here

I don't think it's possible to have the colours not blend into each other.
You can also overlay a simple outline symbol layer to make sure the polygons still have edges.

0
1

It is possible to display multiple values using a polygon with appropriate attribute table data in QGIS.

However, when you want to display multiple values within a polygon you have to use an approach through the properties option of the vector dataset. In the layer's properties dialogue box you will find a tab called "Diagrams" there you could specify which diagram type you want to choose (i.e pie chart, bar graph) that fits best with your dataset.

enter image description here

The result will be a diagram displayed proportionally to the fields you have chosen overlay on each polygon.

enter image description here

You could find more information here at the QGIS documentation page.

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.