# Coloring a map of GeoRegions

I know that I can plot multiple GeoGraphics results on the same map by using something like Show[Graphics@@p1, Graphics@@p2], but it doesn't really work (seems to suffer from some kind of truncation on some parts of the second region).

On a more basic level, I want to simply colorize a map. Each region is generated in the following way:

GeoGraphics[{FaceForm[Red],
Normal[ds[[(Flatten@Position[fileContents, #])]][All,
"Geometry"]]}]


Where # goes from 0 to some number inclusive. I want to show all of these regions on the map, each with their own colors (from 0 to N, I will need at least 8 different colors, it's fine if they get recycled, just not for adjacent regions (adjacency has nothing to do with the value of #)).

Is there a simple way to do this?

I post this example in case it is helpful:

africa = CountryData["Africa"];
col = RGBColor @@@ RandomReal[{0, 1}, {Length[africa], 3}];
GeoGraphics[
africa}]]


• This provided the seed of the answer. As an aside, how can I show labels for each region using GeoGraphics? It seems that GeoLabels is only an option for GeoListPlot and GeoRegionValuePlot? Commented Feb 24, 2015 at 13:37
• Just in case you haven't seen this new M10 function, you could do col = RandomColor[Length[africa]]; Commented Feb 24, 2015 at 18:35
• @ChipHurst thank you I did not know Commented Feb 25, 2015 at 12:30
• @soandos I am sorry I am time poor at present but suspect playing you will achieve desired goal Commented Feb 25, 2015 at 12:32
• It was solved thanks to you, what I actually did is below Commented Feb 25, 2015 at 12:33

Here's a map colouring solution using the graph colouring functionality of IGraph/M.

Take the countries of Europe:

countries = CountryData["Europe"];


Build a graph based on which countries share a border.

borderingQ[c1_, c2_] := MemberQ[c1["BorderingCountries"], c2]

graph = RelationGraph[borderingQ, countries]


Colour and plot!

GeoGraphics@MapThread[{GeoStyling[#2], Polygon[#1]} &,
{countries, ColorData[97] /@ IGVertexColoring[graph]}]


The key function was:

?IGVertexColoring


IGVertexColoring[graph] returns a vertex colouring of graph.

A practical shortcoming of this graph-based map colouring method is that it doesn't make it intuitively obvious where islands belong. Iceland, the Faroese islands, Shetland, the UK, Svalbard and Norway are all blue and are all the in the same area. It is not at all clear to a reader of the map that the Svalbard belong to Norway, Shetland to the UK, and the rest are separate.

For completeness, here is what I ended up with:

temp = ds[[(Flatten@Position[fileContents, #1])]] & /@ (Range[
Length[fileContents]] - 1);
GeoGraphics[
MapThread[{GeoStyling[#1], Normal[#2[All, "Geometry"]]} &, {col, temp}]]


Using GeoStyling instead of FaceForm to make the colors much more bold.