簡體   English   中英

在R中的柵格圖層上繪制shapefile

[英]Plotting a shapefile on a raster layer in R

我想在頂部繪制一個帶有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)

我找到了答案,我會把它放在這里給其他可能遇到相同問題的人。

解決方案很簡單:(只要柵格和shapefile在同一CRS中)

plot(r)

plot(shape, add = TRUE)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM