[R] GADM -- Download World Map for R

Lorenzo Isella lorenzo.isella at gmail.com
Tue Mar 14 15:57:58 CET 2017


Dear All,
Please have a look at the snippet here

http://bit.ly/2mVS8me

This short code addresses precisely one of my needs: to superimpose a
network (created with the igraph library) to a geographical map.
Unlike the case of the example, where a single country is enough, I
need to have a world map in R to which superimpose the network.
Seen that I am far from an expert about plotting maps in R (you may
want to resort to a purely ggplot oriented solution for the map, but
then you need to translate your network into something ggplot
understands -- see http://bit.ly/2mVSOIk ).
For me it would be way simpler to follow the footsteps of the work
done in the previous link, but I cannot download from GADM a world
map.
Does anybody know how to achieve that?
Regards

Lorenzo


#######################################################à
library(raster)
library(igraph)
greece <- getData('GADM', country='GRC', level=1)
df<-data.frame("from" = c("Athens", "Iraklio", "Thessaloniki",
"Patra"), "to"= c("Thessaloniki", "Thessaloniki", "Athens",
"Iraklio"))
meta <- data.frame("name"=c("Athens", "Iraklio", "Thessaloniki",
"Patra"),
               "lon"=c(23.72800,25.13356,22.94090,21.73507),
	                      "lat"=c(37.98415,35.33349,40.63229,38.24628))
			      g <- graph.data.frame(df, directed=T,
			      vertices=meta)
			      lo <- as.matrix(meta[,2:3])
			      plot(greece)
			      plot(g, layout=lo, add = TRUE, rescale = FALSE)



More information about the R-help mailing list