h-a-graham / rayvista

An R plugin for {rayshader} to view a 3D vista anywhere on earth.
GNU General Public License v3.0
107 stars 5 forks source link

3D rendering surface/ground using LiDAR file #20

Closed Saadi4469 closed 3 years ago

Saadi4469 commented 3 years ago

Hello,

First of all, thank you for creating this beautiful package mate. I am using the plot_3d_vista function to 3D render a LiDAR point cloud ground surface data. So, I took the X and Y columns of the LAS file to give to .lat and .long variables, but I get an error while running the plot_3d_vista function. Btw the LiDAR file is in EPSG:32611. How can I fix this? The LAS file when loaded in R is just like a data.frame as seen here.


# LiDAR 3D modeling
LAS_lat = LAS.Ground@data$Y
LAS_long = LAS.Ground@data$X
LAS.G_3D.Render = plot_3d_vista(lat = LAS_lat , long = LAS_long , phi=30)

Error in getClassDim(x, length(x), dim, "POINT") : 
  5158186 is an illegal number of columns for a POINT

Cheers

Saadi4469 commented 3 years ago

The issue seems to be the incompatibility of the package with other EPSGs. Is there a way to make this work with EPSG:32611, which is basically WGS84 UTM Zone11?

Saadi4469 commented 3 years ago

Actually, even when I reproject the LiDAR file to EPSG:4326 I get the same error, as you can see the projection should be compatible now. How can this be fixed?

h-a-graham commented 3 years ago

Hi,

Thanks for the kind words on the package!

So the lat and long arguments accept only one value which generates a point and then using radius, a search radius aroun that point from which to generate the 3d scene.

Rayshader is primarily designed to work with raster data rather than directly on point clouds, although you can use render_points for adding new point data. So if you want to add an overlay on top of a lidar dataset, first you will need to convert it to a raster then you can use the recently added 'dem' argument in plot_3d_vista() to create the overlay (you may need to update rayvista unless you installed quite recently). I suspet the workflow will look something like this - (my personal prefernce for working with point clouds in R is with {lidr}):

#install.packages('lidr')
library(lidr)
library(rayvista)
my_LAS<- readLAS('pathToLas.las')
my_RAS <- grid_terrain(my_LAS)
plot_3d_vista(dem=my_RAS, phi=30)

The CRS of your derived raster should be irrelevant in this case so shouldn't be any need to transform it.

If you would prefer to render colourized points - this can also be done with rayshader by generating a ggplot object with ggplot2::geom_point() and then use rayshader to make the 3d ggplot. If you have a very large point cloud this could be very slow. This approach isn't supported by rayvista so you would need to develop a more specific workflow.

Hope this is helpful. I will also (at some point) try to write some vignettes to make clear what each of the arguments mean/allow.

Let me know how you get on.

Thanks!

Saadi4469 commented 3 years ago

This did work thank you, but the rendering is not detailed, why is that so?

h-a-graham commented 3 years ago

What is the scale of your scene? You can increase the resolution of the overlay by adding 'overlay_detail=16' and I suspect you will also need 'zscale=1' to represent the topography correctly.

If the detail is still insufficient then I suspect that you are reaching the limits of the free esri aerial imagery.

If you can find a better orthomosaic elsewhere then you can use this tutorial to produce the 3d terrain with an overlay:

https://www.tylermw.com/a-step-by-step-guide-to-making-3d-maps-with-satellite-imagery-in-r/