How to draw ggmap with two different administrative boundaries?

走远了吗. 提交于 2019-12-03 08:57:20

You could also get your maps from e.g. GADM:

library(raster)
adm1 <- getData('GADM', country='HUN', level=0)
adm2 <- getData('GADM', country='HUN', level=1)

And let us fortify those for ggplot usage:

library(ggplot2)
fadm1 = fortify(adm1)
fadm2 = fortify(adm2)

And add as many layers and geoms as you wish:

ggplot(fadm1, aes(x = long, y = lat, group = group)) + geom_path() +
    geom_polygon(data = fadm2, aes(x = long, y = lat), 
                 fill = "green", alpha = 0.5) +
    geom_path(data = fadm2, aes(x = long, y = lat), color = "blue") + 
    theme_bw()

Resulting in:


Update: combining your two layers mentioned in the updated questions

m0 + geom_polygon(size = .01,
        aes(x = long, y = lat, group = group, fill = as.factor('red')),
        data = MapC,
        alpha = .6) +
    geom_path(color = 'grey50', size = .1, aes(x = long, y = lat, group = group),
        data=MapP, alpha=.9) +
    guides(fill=FALSE)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!