R:删除tmap地图中的孤岛
我正在尝试使用tmap删除孤岛 我经常使用lims删除ggplot中的孤岛:R:删除tmap地图中的孤岛,r,facet,tmap,R,Facet,Tmap,我正在尝试使用tmap删除孤岛 我经常使用lims删除ggplot中的孤岛: library(tmap) library(ggplot2) library(raster) chile <- getData("GADM",country="Chile",level=1) ggplot()+ geom_polygon(data=chile, aes(x=long, y=lat, group = group), color
library(tmap)
library(ggplot2)
library(raster)
chile <- getData("GADM",country="Chile",level=1)
ggplot()+
geom_polygon(data=chile, aes(x=long, y=lat, group = group),
color = "#666666") +
coord_equal() +
lims(x = c( -77.2,-60), y = c(-60, -15))
我在tmap中使用facet,因为它给我带来了更好的结果,但这对我来说是个问题:
chile2= chile[c(2,4:5,7,8,12:16),]
chile2$group=1
chile3= chile[c(1,3,6,9:11),]
chile3$group=2
map_split=rbind(chile2, chile3)
tm_shape(map_split) +
tm_borders() +
tm_facets(by = "group")
你可以看到岛屿是如何让你得到一张好的平面图的
您知道如何删除tmap地图中的岛屿吗
谢谢您可以从数据集中删除不需要的区域
library(raster)
chile <- getData("GADM",country="Chile",level=1)
xchile <- crop(chile, extent(-85,-59, -61, -14))
库(光栅)
智利
library(raster)
chile <- getData("GADM",country="Chile",level=1)
xchile <- crop(chile, extent(-85,-59, -61, -14))