Closed Jean-Romain closed 3 years ago
The choice of the y-axis being up is a computer graphics convention, and it's the standard used in most OpenGL-based software. Using the z-axis as up is a perfectly fine choice, but it's just a different convention. As you found out, it's not too difficult to translate between the two.
The transposed geometry is due to the different data-ordering conventions used by R matrices and raster data—you either have to flip and transpose yourself, or you can use the render_points()
function in rayshader, which will do it for you:
render_points(extent= bbox, long = las$X, lat = las$Y, altitude = las$Z,size=1)
I believe this is resolved (use the render_points() function when adding outside data, which will account for the internal orientation choices).
Hi,
I was trying to render a LiDAR point cloud on top of the DTM rendered by
rayshader
. Using thelidR
package it was expected to be easy but in practice the axes chosen inrayshader
make this task particularly hard. For example the elevation is rendered on the Y axis instead of the Z axis.Let start by making a DTM with
lidR
Then we can compute the heightmap and calculate the surface color map.
Now we are plotting
Fisrt we can notice that the scene is rendered on (0,0) which makes a lot of sense. But then we can see that:
Then we can try to add the original point cloud. The coordinates of the points being given with a coordinate reference system they don't match with the
rayshader
rendering centered on (0,0) but this is not a problem becauselidR
already hold this case and shift coordinates for a better rendering (a story of floating point accuracy). So here we can compute the offsets to center the points on (0,0)Then if the
rayshader
scene was rendered on X,Y,Z I could do (from lidR v3.0.0)But it does not work because of the axes choices. So we can switch the axis manually
Surprisingly it works but the scene is still inverted. What is surprising actually is the fact that points are inverted as well as if the axes themselves were inverted.
As a conclusion it is very hard to render a real scene and add custom objects. I'd like to understand your axes choices and the rendering inversion and I'd like to know if there is way to tune that easily to make this kind of rendering easier.
Thanks
ps: I know that the question is even harder with a dtm resolution different than 1 but let keep it simple with a resolution of 1.