Reputation: 2435
I am trying to make some colerful maps using spatialpolygons with R. I downloaded the shapefile from gadm.org website and colored the regions as I wanted following http://bl.ocks.org/prabhasp/raw/5030005/ . However, I think the map would look much better if I were able to put on the map also part of the countries Vietnam shares the border with, as in this wikipedia map
I have no clue what to start with, could someone give me a hint? Should I dowload the regional map and then join the regions for the border countries and work at the provincial level for Vietnam? Or can I plot my Vietnam map over the country level one?
Upvotes: 3
Views: 5901
Reputation: 59345
If this is a one-off, I'd be inclined to do it this way.
library(raster)
library(ggplot2)
vietnam <- getData("GADM",country="Vietnam",level=2)
china <- getData("GADM",country="China",level=0)
laos <- getData("GADM",country="Laos",level=0)
cambodia <- getData("GADM",country="Cambodia",level=0)
thailand <- getData("GADM",country="Thailand",level=0)
ggplot(vietnam,aes(x=long,y=lat,group=group))+
geom_polygon(aes(fill=id),color="grey30")+
geom_polygon(data=china,fill="grey60",color="grey80")+
geom_polygon(data=laos,fill="grey60",color="grey80")+
geom_polygon(data=cambodia,fill="grey60",color="grey80")+
geom_polygon(data=thailand,fill="grey60",color="grey80")+
coord_map(xlim=c(-1,1)+bbox(vietnam)["x",],ylim=c(-1,1)+bbox(vietnam)["y",])+
scale_fill_discrete(guide="none")+
theme_bw()+theme(panel.grid=element_blank())
Labelling the border countries is trickier because you have to know where to put the labels, and you can't use the country centroids because they are off the map. I'd be includes to eyeball it, and use annotate(geom="text",...)
.
Upvotes: 5