[R] Trouble with Spatial Data Example Script

Lorenzo Isella lorenzo.isella at gmail.com
Fri Aug 10 22:20:56 CEST 2012


Dear All,
I need to do something relatively simple: generate a map of Europe and  
paint the various states with different colors (only 3-4 are needed)  
according to a rule.
I would like to keep it as simple as possible and the script resorting to  
the sp package that I found at

http://bit.ly/Oc71ub

is exactly what I am looking for (I need to repeat the exercise with  
Europe instead of Switzerland and to have a legend).
However, when I try to run the script (which I also paste at the end of  
the email), well, nothing happens and I certainly do not see a map of  
Switzerland.
I am not familiar with the sp package, but am I missing the obvious?
Any help is appreciated.
Best Regards

Lorenzo

########################################à

library(sp)
con <- url("http://gadm.org/data/rda/CHE_adm1.RData")
print(load(con))
close(con)



language <- c("german", "german", "german","german",
  "german","german","french", "french",
  "german","german","french", "french",
  "german", "french","german","german",
  "german","german","german", "german",
  "german","italian","german","french",
  "french","german","german")
gadm$language <- as.factor(language)
col = rainbow(length(levels(gadm$language)))
spplot(gadm, "language", col.regions=col, main="Swiss Language Regions")

###########################################



More information about the R-help mailing list