在R中将一个shapefile绘制在一个栅格图层上

4
我想将一个栅格图层与一个点状的shapefile叠加在一起。我查看了之前的答案,但是仍然有问题。我可以单独绘制点状shapefile和栅格图层,但无法同时绘制它们。
据我所见,它们应该处于相同的投影和位置。
require(maptools) 

myproj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
shape <- readShapeSpatial("directory/mypoints.shp", proj4string = CRS(myproj))

plot(r <- raster(listVI[200]))
plot(shape)
1个回答

6
我找到了答案,我会在这里分享给其他可能遇到同样问题的人。
解决方案很简单:(只要栅格和shapefile在相同的CRS中)
plot(r)

plot(shape, add = TRUE)

1
可以在rasterVis中使用layer。请参考?rasterVis::levelplot中的示例。 - jbaums

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接