3

I want to divide each country into three separately coloured areas, like this:

enter image description here

The proportions of the three coloured areas must based on three columns of attribute data in the country shapefile's attribute table (representing percentages of a country's total energy production).

Attribute table showing each country's energy sources in percentages of total energy production

The two ways I can think of doing this are:

  1. Using a fill method to colour each country with three different solid colours proportionally based on the attribute data, or
  2. To split each country's polygon into three polygons proportional to the attribute data (and then they can easily be given separate colours).

For the first method, the only solution I have found is Ed Rollason's technique using gradients, but I want to achieve the same thing using solid colours, not gradients.

For the second method, there is the Split Polygon plugin but that doesn't allow one to use attribute variables.

Does anyone know a method to achieve this?

  • Would it be acceptable if the width of each stripe was proportional to the attribute, instead of the area? Because that's much easier to achieve. – csk Nov 29 '18 at 19:07
  • for an area-based solution, see here: gis.stackexchange.com/questions/286102/… – csk Nov 29 '18 at 19:08
1

How to fill a polygon with stripes where the width of each stripe is proportional to an attribute

Build a multi-layered symbol from the bottom up, with layers as follows.

  • Final layer - outline

    Symbol Layer Type: Outline: Simple Line

  • Fourth layer and higher - follow the pattern set by the second and third layers below

  • Third layer - attribute3

    Symbol Layer Type: Geometry Generator

    • Geometry type: Polygon/Multipolygon
    • Expression: intersection($geometry, translate(bounds($geometry), ("attribute2"/100)*bounds_width($geometry), 0))

enter image description here

  • Second layer - attribute2

    Symbol Layer Type: Geometry Generator

    • Geometry type: Polygon/Multipolygon
    • Expression: intersection($geometry, translate(bounds($geometry), ("attribute1"/100)*bounds_width($geometry), 0))

enter image description here

  • First (Bottom) layer - attribute1

    Symbol Layer Type: Simple Fill

enter image description here

Note that the expression for each layer uses the attribute for the previous layer.

My attribute values are whole number percentage values (eg 20% is stored as 20). If yours are decimals (eg 20% is stored as 0.2), substitute the attribute name "attribute1" instead of ("attribute1"/100) in the expressions provided.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.