简体   繁体   English

在R中绘制3D栅格(DEM)?

[英]Plotting 3D Raster (DEM) in R?

I am trying to plot a 3D surface of a DEM imported as a raster in R using the raster package. 我正在尝试绘制使用R raster包在R中作为栅格导入的DEM的3D表面。

So far, my code is: 到目前为止,我的代码是:

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)")

Which works perfect for a 2D plot of the DEM, but, when I try to make it 3D, with: 对于DEM的2D图,它非常适合,但是,当我尝试使其成为3D时,可以使用:

plot3d(DEM)

or 要么

surface3d(DEM)

It says cannot coerce type 'S4' to vector of type 'double' . 它说cannot coerce type 'S4' to vector of type 'double'

I am sure that answer is very simple but I have not managed to get it working with the similar questions that I have found. 我敢肯定,答案非常简单,但是我没有设法将其与类似的问题一起使用。

The raster() function returns RasterLayer objects, and I suspect that the plot3d() and surface3d() functions in the rgl package do not (or do not fully) support RasterLayer objects. raster()函数返回RasterLayer对象,而我怀疑rgl包中的plot3d()和surface3d()函数不(或不完全)支持RasterLayer对象。

The plot3D() function in the RasterVis package, however, does. 但是,RasterVis包中的plot3D()函数可以。 Give this a try: 试试看:

install.packages("rasterVis")
library(rasterVis)
plot3D(DEM)   # note: 3D not 3d

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM