[R] mapping data to a geographic map of Europe

Jim Lemon jim at bitwrit.com.au
Wed Oct 30 22:59:18 CET 2013

On 10/31/2013 03:04 AM, paladini at trustindata.de wrote:
> Hi Jim,
> thats the second time that you helped me in a short while so thanks a lot!
> But it seems to me quite laborious and error-prone to first select all
> the relevant countries in this long list and then to create a color vector.
> But perhaps I get it all wrong.
> For the color vector I first did this
> imagecolors<-color.scale(mydata$GPIndex ,c(1,0,0),0,c(0,0,1))
> because I wanted the colors to scale from dark red (bad ones) to dark
> blue (good ones).
> But it went somehow wrong. By the way can you tell me what I did wrong?
> Nevertheless I than createt a color vector looking loke this:
> eurocol=c("#FF0000FF",8,"#710000FF","#390000FF",8,8,"#390000FF",rep(8,10),"#2F0000FF"
> ,8,"#000000FF",8,"#000000FF","#000000FF" ,"#000055FF",8,"#000064FF",2,
> "#000083FF",8,8,"#00008BFF" ,"#0000F0FF" ,rep(8,20),"#0000F7FF"
> ,rep(8,18),"#0000FFFF", rep(8,120))
> And than
> world.map<-map('world', fill = TRUE,col =eurocol
> ,xlim=c(-12,35),ylim=c(37,70))
> Beside the wrong colors it worked okay.
> But I am not really happy with this solution.
> Did I misapprehend you?
Hi Claudi,
Maybe. You write that the transformation of GPIndex to colors "went 
wrong". Let's see:

# make up GPIndex
# transform to colors

This gives me what I would expect, and checking the colors against the 
country names (world.map$names) looks like the correct colors have been 
displayed. Obviously I left a lot of areas out (missed UK and Ireland 
for example) as I didn't want to overplot individual countries with 
areas. Does this look okay to you?


More information about the R-help mailing list