简体   繁体   English

R脚本-通过对X,Y,Z点进行插值的3D表面

[英]R Script - 3D Surface via Interpolation of several X,Y,Z points

I would like to use R and have it consume the few X,Y,Z points of data that I have (the black dots in the image) and then generate 300x300 XYZ points that would represent the 3D Surface Plot seen colored in the image. 我想使用R并消耗一些我拥有的X,Y,Z点数据(图像中的黑点),然后生成300x300 XYZ点,这些点代表图像中彩色的3D表面图。 I would like the output to simple be three columns, the X,Y, and Z points. 我希望输出简单地为三列,即X,Y和Z点。 I've tried the following, but it doesn't seem to generate the data I need. 我已经尝试了以下方法,但是它似乎没有生成我需要的数据。 I need the X,Y,Z points to generate an image in another program (spotfire) and do not need to do any graphics in R. Any help would be appreciated! 我需要X,Y,Z点来在另一个程序(Spotfire)中生成图像,并且不需要在R中做任何图形。任何帮助将不胜感激! Thanks. 谢谢。

3D Surface Plot with Points 带点的3D表面图

> require(akima)
> points = read.csv("points.csv", header = TRUE)
> print(points)
         x       y    z
1   400.01  650.01 2.70
2   150.00  780.00 3.40
3   250.00  780.00 3.10
4   800.00  700.00 1.00
5  1000.00  680.00 1.00
6  1500.00  680.00 0.75
7  1700.00  700.00 1.00
8  1700.00  790.00 1.25
9  1600.00 1000.00 1.20
10 1750.00 1000.00 1.00
11 1800.00 1650.00 0.60
12 1400.00 1650.00 0.65
13 1000.00 1650.00 0.80
14  500.00 1650.00 0.90
15  150.00 1650.00 1.30
16  150.00 1050.00 3.90
17  500.00 1000.00 3.00
> s=interp(points$x,points$y,points$z,xo=seq(min(points$x),max(points$x),length=300),yo=seq(min(points$y),max(points$y),length=300))

It works for me. 这个对我有用。 I think all you need to do is transform the final list into a matrix. 我认为您需要做的就是将最终列表转换成矩阵。

s1 <- interp2xyz(s)
dim(s1)
# [1] 90000     3

A lot of points generate a NA values for z value 很多点生成z值的NA值

sum(is.na(s1[,3]))
# [1] 4897

You might choose to exclude those points or use extrapolation. 您可以选择排除这些点或使用外推法。

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

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