我想将地图的放大部分添加到原始地图中,并将最终产品作为一张地图显示原始地图以及放大/缩放部分。以meuse
数据集为例:
library(sp)
library(lattice)
data(meuse)
coordinates(meuse)=~x+y
gridded(meuse)<-TRUE
rasters.m<-list()
for (i in 1:12){
rasDF <- raster(meuse, layer=i)
rasters.m[[i]]<-rasDF
}
stack.sp<-stack(rasters.m)
plot(stack.sp) # gives a gridded view of the stacked rasters. But now I would like to zoom in..
zoom.ent<-zoom(stack.sp,1) # The zoomed in portion appears as a new window, with the boundaries of the zoomed area highlighted in red on the original map.
我不确定raster
或rasterVIS
包中是否有命令允许将光栅的放大部分添加到原始地图上。我尝试了par
函数,但这不起作用。任何建议都会受到欢迎。
答案 0 :(得分:2)
这或多或少是同一个问题you asked here。对于Raster*
个对象,您必须使用shift
函数。结果可以与+.trellis
包的latticeExtra
函数结合使用:
library(raster)
library(rasterVis)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
rZoom <- crop(r, extent(180000, 181000, 330000, 331500))
displaced <- shift(rZoom, x = -1200, y = 2000)
levelplot(r) + levelplot(displaced)