我正在尝试使用raster包绘制在R中作为栅格导入的DEM的3D表面.
到目前为止,我的代码是:
DEM <- raster("DSM_TLS_2010_25cm_v4.tif")
DEM <- setMinMax(DEM)
col <- rainbow(20)
plot(DEM, col=col, zlim=c(0,790.22), main="Digital Elevation Model (DEM)")
Run Code Online (Sandbox Code Playgroud)
哪个适用于DEM的2D绘图,但是,当我尝试使其成为3D时,使用:
plot3d(DEM)
Run Code Online (Sandbox Code Playgroud)
要么
surface3d(DEM)
Run Code Online (Sandbox Code Playgroud)
它说cannot coerce type 'S4' to vector of type 'double'.
我确定答案非常简单,但还没有设法让它与我发现的类似问题一起工作.欢迎任何帮助!
raster()函数返回RasterLayer对象,我怀疑rgl包中的plot3d()和surface3d()函数没有(或不完全)支持RasterLayer对象.
但是,RasterVis包中的plot3D()函数可以.尝试一下:
install.packages("rasterVis")
library(rasterVis)
plot3D(DEM) # note: 3D not 3d
Run Code Online (Sandbox Code Playgroud)