Skip to content
Prev 14026 / 29559 Next

Coloring Canada provinces in raster

Vielen-vielen Dank, Rafael.
A factor!
That does exactly what I wanted! Thanks a million!

Still can't figure out how to get rid of the legend on the right. I
couldn't find the solution here:
http://127.0.0.1:14681/library/sp/html/spplot.html
Or, if it's impossible, maybe one could at least change the order in
the legend (to have 1 at the top and 6 at the bottom)?
Finally- anyone knows how to delete the borders between small
geographic units and only leave borders between provinces?

Thank you very much, everyone for your help!
Dimitri

The working code so far:

library(raster)
can2<-getData('GADM', country="CAN", level=2)
nrofunits<-length(can2$NAME_2)
groups<-c(rep(1:6,(nrofunits %/%
6)),rep(1,5))[order(c(rep(1:6,(nrofunits %/% 6)),rep(1,5)))]
# adding values (grouping values) to "data":
can2 at data[["groups"]]<-groups
can2 at data$groups<-as.factor(can2 at data$groups)
classcolors <- rainbow(6)
spplot(can2,zcol="groups",col.regions=classcolors)
On Fri, Jan 27, 2012 at 3:25 AM, Rafael W?est <rafael.wueest at wsl.ch> wrote: