用于 R 中 3D 表面预测的薄板样条

Thin Plate Spline for 3D surface prediction in R

我试过这个答案

get a surface plot in R

但这并没有真正帮助。 我想在 XYZ 数据帧上执行 TPS(使用 Fields{} 中的 Tps),其中 xy 是坐标,z 是厚度。然后我想先在 TPS 之前然后在 TPS 之后可视化情节..?这可能吗。 然后我想为给定的一组新 xy 坐标提取预测厚度..?

如果可行请告诉我

我的 Dataframe 是这样的,dataframe 叫做 LSP:

time   PART   MEAS    PARTSUB   XLOC   YLOC
xxxx   1      1.956   a         -3465  -94350
xxxx   1      1.962   a         -3465  -53850
xxxx   1      1.951   a         50435  -40350
xxxx   1      1.958   a         -57365 -40350

所以我尝试了这个:

LSP.spline <- Tps(LSP[,5:6], LSP$MEAS)
out.p <- predict.surface(LSP.spline, xy = c(1,2))
plot.surface(out.p, type="p")

但是 out.p 只是 NULL..?

所以尝试情节给了我:

Error in nrow(z) : argument "z" is missing, with no default

感谢任何帮助。 保罗.

predict.surface 现在是一个过时/弃用的函数。请改用 predictSurface

fit<- Tps( BD[,1:4], BD$lnya)  # fit surface to data 

# evaluate fitted surface for  first two 
# variables holding other two fixed at median values

out.p<- predictSurface(fit)
surface(out.p, type="C") 

Thanks for that - how about my second question....how can I extract predicted surface thickness values for a given set of XY locations..?

使用predict函数。阅读 ?predict.Tps。对于上面的例子,假设我们想要在 BD[, 1:4] 中的前 4 个位置进行预测,我们可以做

predict(fit, x = BD[1:4, 1:4])

#          [,1]
#[1,] 11.804124
#[2,] 11.804124
#[3,]  8.069056
#[4,]  9.501551

一般情况下,传递 x 一个两列矩阵。