小编Rod*_*_BC的帖子

R:使用 ggplot2 对地图进行分面

我正在尝试使用 ggplot2 对地图进行分面,因为它比 tmap 包更快。遗憾的是我得到的地图并不是我想要的。

library(ggplot2)
library(raster)
library(ggspatial)


chile  <- getData("GADM",country="Chile",level=1)

chile2= chile[c(2,4:5,7,8,12:16),]
chile2$grupo=1
chile3= chile[c(1,3,6,9:11),]
chile3$grupo=2
mapa=rbind(chile2, chile3)

ggplot() +
  layer_spatial(mapa) +
  lims(x = c( -77.1,-65), y = c(-57, -15))+
  facet_wrap(~grupo)
Run Code Online (Sandbox Code Playgroud)

ggplot 地图

遗憾的是上面的地图不是我需要的。通过 tmap,我得到了下面的地图,这正是我真正需要的地图:

TM 地图

你知道如何使用ggplot2解决这个问题吗?

google-maps r facet ggplot2

3
推荐指数
1
解决办法
704
查看次数

标签 统计

facet ×1

ggplot2 ×1

google-maps ×1

r ×1