[R-sig-Geo] Colouring maps so that adjacent polygons differ in colour

Virgilio Gómez-Rubio virgilio.gomez at uclm.es
Tue Apr 5 16:38:55 CEST 2011


Apparently, package gcolor provides an algorithm to colour a map:



mat.nc<-nb2mat(nb.nc, style="B")


spplot(xx, "COL")

It uses 4 colour for North Carolina, but I am not sure whether this is
THE 4-colour algorithm:

> table(gcol)
 1  2  3  4 
17 27 28 28 

Hope this helps,


El mar, 05-04-2011 a las 15:24 +0100, Barry Rowlingson escribió:
> On Tue, Apr 5, 2011 at 3:13 PM, Mathieu Rajerison
> <mathieu.rajerison at gmail.com> wrote:
> > I don't know how to accomplish that in R, but in QGIS, you can use the
> > Topocolours plugin to accomplish that.
>  topocolours (I wrote that!) uses the same greedy algorithm once its
> worked out the connectivity. I did make topocolours have the
> flexibility to choose other algorithms but only implemented the greedy
> one. The problem with real world maps is that some features have more
> than one polygon (islands) and if you want them all coloured the same
> you might not be able to do a 4-colour colouring!
>  I also used ColorBrewer colours!
>  It might be worth taking out the construction of the adjacency list
> to another function, since I found recently that poly2nb gave very
> different adjacencies to functions in rgeos.
> Barry
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

More information about the R-sig-Geo mailing list