r - How to add a country to country.map-country.region for a choropleth map using choroplethr- choroplethrMaps- -


i have made map using choroplethr , choroplethrmaps packages . problem in order plot country , country must contained in country.regions , country.map data frames included in choroplethrmaps package. lets map

install.packages("mapproj");library(mapproj) install.packages("choroplethr") install.packages("choroplethrmaps") library(choroplethr);library(choroplethrmaps);library(ggplot2) data(country.map) data(country.regions) a<-c(4.1,2.5,0.4,6.4,1.4,1.8,3.8,1.3,2.3,8.4,5.2,1.9,0.8,1.5,2.1,1.2,3.8,1.4,3.1,0.8,4.0,1.3,4.8,2.6,2.8,2.3,3.1,2.5,na,na,na,na,na,na,na,na,na,na,na,na) target<-c("austria","belgium","bulgaria","switzerland","cyprus","czech republic","denmark",           "estonia","spain","finland","france","greece","croatia","hungary","ireland","italy",           "lithuania","luxembourg","latvia","norway","poland","portugal","romania","sweden",           "slovenia","slovakia","turkey","united kingdom","russia","belarus","germany","ukraine","iceland"           ,"netherlands","bosnia , herzegovina","albania","montenegro","macedonia","moldova","kosovo") datas<-data.frame(region=target,value=a) datas$region<-as.character(datas$region) gg <- country_choropleth(datas,num_colors=1,zoom=target) gg <- gg + xlim(-25.266001, 71.869301) gg <- gg + ylim(34.536311, 70.008797) gg <- gg + coord_map("lambert", lat0=27.636311, lat1=81.008797) gg<-gg+scale_fill_continuous(name="%",low="yellow", high="orange", na.value="grey") gg<-gg+theme(plot.background=element_rect(fill="dodgerblue",colour="black"),legend.position="bottom",legend.background = element_rect(),legend.text = element_text(size = 13, colour = "black"))  gg 

enter image description here

everything goes fine because every region have in data frame contained same name in country.regions , country.map .

my problem want add malta , serbia regions map , have data , , cant because not contained developers in country.regions , country.map data frames .i tried add names of countries country.regions , latitudes , longtitudes in country.map (using geocode("malta") function of maps package) not work way

thank using choroplethr.

i think find difficult add country ?country.map. geocode function refer return single longitude , latitude point. draw country, need points represent entire border.

however, wrote choroplethr handle cases this, people want use choroplethr interface own map. here how recommend started.

  1. read wiki page mapmaking r programmers
  2. read vignette creating own maps
  3. if have further questions, might want post on choroplethr google group

essentially, think want find shapefile meets needs , learn qgis enough open shapefile , poke around in it. after should few lines of r code , (hopefully) simple debugging have choroplethr "just work" you.

i'm sorry can't provide more specific advice. don't know go european shapefiles. if find out, or if else posts it, add list.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -