[R] How to draw a map of Europe?

David Winsemius dwinsemius at comcast.net
Sun Mar 20 02:51:11 CET 2011


On Mar 19, 2011, at 8:32 PM, Sally Luo wrote:

> Hi R users,
>
> I need to draw a map of select European countries with country names  
> shown
> on the map.  Does anyone know how to do this in R?

Adding a tiny bit to the material produced from a search and finding  
something from Roger Bivand in response to Rense Nieuwenhuis:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/85586.html

require(maps)

  country2001 <- c("Austria", "Belgium", "Switzerland",
  "Czechoslovakia", "Germany", "Denmark", "Spain", "Finland", "France",
  "UK", "Greece", "Hungary", "Ireland", "Israel", "Italy",
  "Luxembourg", "Netherlands", "Norway", "Poland", "Portugal",
  "Sweden", "Slovenia")
  color2001 <- c("green", "yellow","red","red", "red", "red", "red",
  "red", "green", "red", "red", "red", "red", "red", "red", "red",
  "red", "blue", "red", "red", "red", "orange")

europe$names[grep("Sicily", europe$names)] <- "Italy:Sicily"
europe$names[grep("Sardinia", europe$names)] <- "Italy:Sardinia"
match <- match.map(europe,country2001)
color <- color2001[match]
map(database="world", fill=TRUE, col=color,  
xlim=c(-25,70),ylim=c(35,71))

text(0, 45, "France")


>
> Also, is it possible to draw a historical map of European countries  
> using R?
>
> Thanks a lot for your help.
>
> Maomao
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list