I have a layer of the world that contains 200 rows.

I am required to color the map with six selected colors, the rainbow colors.

enter image description here

I figure that I can save selected countries and save them separately.

enter image description here

Once they saved I can upload them and make the color ramp I needed.

enter image description here

However, I was wondered is there a faster way to do this without making six layers and without choosing each country manually in the Layer Styling bar panel.

enter image description here

2 Answers 2


Following further clarification by Nitzan Matan, this is another map representation.

enter image description here

This categorization was made by round((y(centroid($geometry))+80)/30) .

To divide latitude range (-90 ~ +80) in this sample data from Natural Earth into 6 zones (bands), I first added 80 and divided by 30. You will need to modify these numbers according to your dataset.

enter image description here

Now change the color to fit with your rainbow palette.

NB One caveat - you will notice Alaska is green. If you want it to be like Russia and Canada, consider breaking US into parts.

  • Very smart!, Can you explained more about the latitude range? Dec 9, 2018 at 9:36
  • 2
    @NitzanMatan Yes, more specifically the latitude ranges (-90.00000 ~ 83.64513) and found as part of Extent in the Layer Properties | Information. But I need to know only the y-coord of centroid so it does not have to be such precise.
    – Kazuhito
    Dec 9, 2018 at 9:48

As you are using QGIS 3.4.2, you can use Topological coloring Tool, which is in the Processing Toolbox | Cartography.

Start this tool and give 6 (any number of colors you want to have) in the Minimum number of colors and hit Run. It will return a new layer Colored with an additional integer field color_id.

So the last step is to open the Layer Property of this layer and set Categorized color scheme on the color_id column (field). You then change each of these 6 random colors to your rainbow palette.

enter image description here

  • The new color id are random, I need then to be from the bottom up like the flag. Dec 9, 2018 at 8:41
  • Sorry @NitzanMatan I honestly do not understand your comment. Could you expound it a little bit more?
    – Kazuhito
    Dec 9, 2018 at 8:58
  • Sure, in your answer you made 6 colored id, They are scattered randomly. In group 1 there are row both in Africa and the U.S. I need that Russia and Canada will be one color, U.S and Europe and so on. Thanks! Dec 9, 2018 at 9:10
  • 1
    Aah, color bands like the flag? Gotcha! Thanks @NitzanMatan for clarification.
    – Kazuhito
    Dec 9, 2018 at 9:15

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.