I'm creating a series of reference maps that need to differentiate between administrative regions within a country. I created a new color ramp using ColorBrewer Dark2 with 8 categories.

My administrative units are in sequential order, so when I classify them, the color ramp groups them in order, like so:

enter image description here

The polygons are also placed based on this order, so all of my administrative regions are roughly grouped like so: enter image description here

This obviously doesn't work well--the point is to easily differentiate between different administrative units. I want each country to look more like this: enter image description here

Thus far, I have been doing all stylizing by manually changing each administrative region's color so that none of the same colored polygons are touching and there are roughly the same number of each color within a country (so 3 pinks, 3 purples, 3 yellows, etc.). I want to be able to automate this process. I think that I need to use rule-based rendering, but I'm not sure how?

Can anyone point me in the right direction for automating this stylization? I get the feeling that I'll need to use some sort of if-then statement to loop through the regions, but this is not my area of expertise.

(Also, I'm using NaturalEarthData shapefiles with custom GIDs if anyone is interested in recreating my polygons.)

  • as this is NaturalEarth data, check the fields - are there fields named like MAPCOLOR8? If so, just use those (MAPCOLOR8 has 8 values designed so as to avoid neighbours with the same colour). This is certainly available with country level polygons, not tried with admin regions.
    – Steven Kay
    Sep 7, 2016 at 18:05
  • @StevenKay this is a cool feature that I didn't know about! Unfortunately, it seems that the 'mapcolor' column only applies to country level data and does not extend to administrative level. Thanks for the tip though!
    – Lauren
    Sep 7, 2016 at 18:28
  • It may be difficult to find a solution for 8 colors but for 4 distinct colors you could check if you can find something useful from here gis.stackexchange.com/tags/four-color-theorem/hot.
    – user30184
    Sep 7, 2016 at 20:59

1 Answer 1


There's a (totally 100% unsupported) plugin at https://github.com/nyalldawson/topocolour which will add an attribute to your data which handles this.

You'll need to manually download that plugin and copy to your .qgis2/python/plugins folder. It's not available in the plugin repositories.

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.