how to use the rayshader packge for 3D surface from x, y, z

127 Views Asked by At

imagine I have a 3 columns matrix x, y, z where z is a height/intensity of x and y.

x = runif(1000)
y = runif(1000)
z = rnorm(1000)

How to use the rayshader packge for 3D surface from x, y, z?

although the rgl could do it, i think is it possible to directly use the rayshader for 3D surface from x, y, z?

Thanks hees

1

There are 1 best solutions below

0
On

You could use akima::interp to approximate the surface with a matrix of values, and maybe rayshader::ray_shade can handle that. Code would be

m <- akima::interp(x, y, z, nx = 200, ny = 200)
s <- rayshader::ray_shade(m$z)

This gives a matrix of shade values; it doesn't draw anything. To draw something, you'll need to turn those values into colours, and display them. For example,

plot(as.raster(s))

which gives this plot:

enter image description here