R how to add border countries to a country spatialpolygons map -



R how to add border countries to a country spatialpolygons map -

i trying create colerful maps using spatialpolygons r. downloaded shapefile gadm.org website , colored regions wanted next http://bl.ocks.org/prabhasp/raw/5030005/ . however, think map much improve if able set on map part of countries vietnam shares border with, in wikipedia map

i have no clue start with, give me hint? should dowload regional map , bring together regions border countries , work @ provincial level vietnam? or can plot vietnam map on country level one?

if one-off, i'd inclined way.

library(raster) library(ggplot2) vietnam <- getdata("gadm",country="vietnam",level=2) china <- getdata("gadm",country="china",level=0) lao people's democratic republic <- getdata("gadm",country="laos",level=0) kingdom of 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 border countries trickier because have know set labels, , can't utilize country centroids because off map. i'd includes eyeball it, , utilize annotate(geom="text",...).

r maps

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -