4

I have a unique layer (a map of a country divided in regions) which I'd like to to style differently according to a variable. I would like to color country regions according to a variable that changes from a map to another.

Here is the sample table that I have:

enter image description here

I would like to automatically create 3 maps with regions that are colored:

  • Map 1: regions colored according to car registrations in 2010
  • Map 2: regions colored according to car registrations in 2011
  • Map 3: regions colored according to car registrations in 2013
  • etc..

I say automatically because I have to create hundreds of maps of the same country, colored each time differently.

I'm currently running QGIS 2.16.

1

You need to set up an atlas. If I am understanding correctly you want a map showing all regions, with graduated colour fills according car registrations but for different years?

You will need to transpose your table so that the rows are the different years and the columns are the different regions. Use this layer as the coverage layer for the atlas in the print composer.

To get a colour scale for the numbers of registrations, you need to use rule-based styles on the layer containing the geometry for your regions. You will need a rule for each year which will be something like:

attribute('$atlas_feature','year') = 2010

Where the column name in csv or registration data is "year" and in this case the rule will only work for 2010.

You will then need to set a data-defined variable for the fill colour in each rule. If you are after a colour range you will need to something like:

colour(rgba(255,0,0,scale_linear(num_registrations,0,100000,0,255))

This would give you a red fill, with transparency scaled from 0 for 0 registrations to 255 (100%) for 100000 sales. You will need to adjust these as appropriate.

  • Thank you very much George. Any news regarding the possibility to do this? – vic90nfsu Jan 24 '17 at 9:21
  • See edited answer. The atlas facility is amazing as is the ability to use expressions all over the place. – George of all trades Jan 24 '17 at 9:57
  • Sorry for the silly questions, but I'm a real newbie using QGIS. I transposed the table and I used it as layer coverage. What I don't understand is where you put the expressions for the atlasfeature and the colour.. I don't get that part.. – vic90nfsu Jan 30 '17 at 10:17
  • Sorry just noticed your comment, the rule-based styles are set in the model, not the composer, by right-clicking on the layer name in the layers panel --> properties --> styles --> drop-down at the top (default "single symbol") --> "rule-based". – George of all trades Feb 16 '17 at 22:48

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.