[R] GADM -- Download World Map for R

Jim Lemon drjimlemon at gmail.com
Tue Mar 14 23:21:54 CET 2017


Hi Lorenzo,
See:

http://www.gadm.org/version2

Jim


On Wed, Mar 15, 2017 at 1:57 AM, Lorenzo Isella
<lorenzo.isella at gmail.com> wrote:
> 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)
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list