dear all, I'm a newbie in map tools. I was asking to perform an apparently very simple task. I have a list of countries (about fifty all over in the world) scored with a real positive value. Eg
Country score Italy .56 UK .58 Korea .41 Mexico .63 ... I wish to plot geographical maps where every country is filled with a color depending on his score. Using maptools library and wrld_simpl I can easily perform the world map. Here my code: ######################################################### ### plot the world map patramp = colorRamp(c(rgb(0,0,.7),"red"))# my personal ramp color palette library(maptools) load(url("http://spatial.nhh.no/R/etc/TM_WORLD_BORDERS_SIMPL-0.2.RData")) country2 = c("Albania", "Argentina", "Australia", "Austria", "Belgium", "Belarus", "Brazil", "Bulgaria", "Canada", "China", "Colombia", "Croatia", "Denmark", "Egypt", "United.Arab.Emirates", "Estonia", "Philippines", "Finland", "France", "Germany", "Japan", "Jordan", "Greece", "India", "Indonesia", "Iran", "Ireland", "Israel", "Italy", "Latvia", "Libya", "Lithuania", "Malaysia", "Mexico", "Morocco", "Norway", "Netherlands", "Pakistan", "Poland", "Portugal", "United.Kingdom", "Czech.Republic", "Romania", "Russia", "Serbia", "Singapore", "Syrian.Arab.Republic", "Slovak.Republic", "Slovenia", "Spain", "United.States", "South.Africa", "Korea.South", "Sweden", "Switzerland", "Thailand", "Taiwan.Province.of.China", "Tunisia", "Turkey", "Ukraine", "Hungary", "Venezuela", "Vietnam") # The my countries' names country.all = wrld_simpl$NAME # countries' names as coded in wrld_simpl n.all = length(country.all) col.map = numeric(n.all) # grep country2 in country.all for (i in 1:length(country2)){ col.map[grep(country2[i],country.all)] = runif(1) # assign a random score to country i } # it certainly exists a cleaner coding for this but it's not my first thought now c2 = col.map!=0 # set countries with score != 0 is not listed in country2 col.map2=col.map col.map2[!c2]=rgb(.95,.96,.97) # be grey the countries not listed in country2 object col.map2[c2]= rgb(patramp(col.map[c2])/255) # ramp the remaining plot(wrld_simpl,col=col.map2,axes=T) # nice plot ### end of program ######################################################### Now what if I wish to zoom on some sub world regions such as Eastern Europe or America or any other user defined contiguous sub group? Russia is a large country I could be interested in cutting it in two peaces eastern and western. Can I do it using wrld_simpl or should I search for other data? If so where can I find free maps data? Some documentation exists but it seems sparse to me. Any hints will be appreciated. Thanks in advance, Patrizio ______________________________________________ R-help@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.