Search code examples
rtifflidarlidar-datalas

Creating orthomosaic from *.las point cloud in R


Is there a way to export a *.las point cloud in R to a orthomosaic? I loaded my las-file containing the points with the package lidR. I want to export a tif which shows the point cloud from above in RGB, similar to what an orthophoto would look like. The data was collected using a terrestrial laser scanner.

point cloud

this is what I want


Solution

  • Okay, so I figured out how to do it, although it's not very elegant:

    # load data
    points <- readLAS(input_path)
    
    # returns the RGB values for the highest points
    RGBZ <- function(r,g,b,z) {
      bands = list(
        R = r[which.max(z)],
        G = g[which.max(z)],
        B = b[which.max(z)]
      )
      return(bands)
    }
    
    # create & save ortho
    ortho <- grid_metrics(points, ~RGBZ(R,G,B,Z), res = 0.1)
    writeRaster(ortho, output_path)