我有以下数据集,需要根据这组数据(60个3D点)绘制曲面。这里,X,Y是水平平面坐标,Z是垂直/高度坐标。
p = read.csv("points.csv")
PTS X Y Z
1 101 481897.9 5456408 94.18695
2 102 481888.8 5456417 94.30702
3 103 481877.0 5456410 94.29034
4 104 481879.9 5456425 94.25546
5 105 481872.7 5456424 94.09370
在查看了几个帖子并尝试在几个库中使用函数之后,我仍然无法找到正确绘制曲面的方法。我尝试过以下方法:
library(plotly)
plot_ly( y= Y, x = X, z = Z, data=p, type = "surface") #returns empty graphic frame
PX = data.matrix(p$X)
PY = data.matrix(p$Y)
PZ = data.matrix(p$Z)
library(plot3D)
surf3D(PX, PY, PZ)
#returns: Error in if (is.na(var)) ispresent <- FALSE else if (length(var) == 1) if (is.logical(var)) if (!var) ispresent <- FALSE :
argument is of length zero
library(lattice)
wireframe(p$Z ~ p$X*p$Y, data = p) #returns just a cube
library(rgl)
surface3d(p$X,p$Y,p$Z)
#returns: Error in rgl.surface(x = c(481897.916, 481888.8482, 481876.9524, 481879.9393, : y' length != 'x' rows * 'z' cols;
#although there are 60 data points in the form (X,Y,Z) in the data set, with no points missing any coordinate
我一定是在做一些可怕的错误。有人会介意指出错误是什么吗?
答案 0 :(得分:1)