0

I have successfully implemented the Rumple_Index example provided in the LidR book. I am now trying to calculate the same Rumple_Index for my forest field plots. I am trying to integrate the Rumple_Index function used for the landscape analysis at my plot scale. I am using code to do this that I have used to calculate Zmetrics for the plots already (substituting the rumple_Index function).

The error I am getting now is:

Error in UseMethod("readLAS", files) : 
  no applicable method for 'readLAS' applied to an object of class "c('cluster', 'multiprocess', 'future', 'function')"
Called from: readLAS(cluster)

This is a simplified version of the code I am trying to run.

rumple_index_surface = function(cluster, res)
{
  las = readLAS(cluster)
  if (is.empty(las)) return(NULL)
  las <- filter_surfacepoints(las, 1)  
  rumple <- grid_metrics(las, ~rumple_index(X,Y,Z), res)
  bbox <- raster::extent(cluster)
  rumple <- raster::crop(rumple, bbox)
  return(rumple)
}

LASlist <- list.files(path to clipped LAZ plots) # create a list of the LAZ files to cycle through

getMetrics <- data.frame() 

for ( i in LASlist) {
  lidar = readLAS(i)
  getMetrics <- rbind(getMetrics, cloud_metrics(lidar, ~rumple_index_surface(cluster, res = 25)))
}

How can my code be improved?

0

1 Answer 1

2

You can simply compute the rumple index from the XYZ coordinates of your plots

las <- readLAS(i)
las <- filter_surfacepoints(las, 1)  
ri  <- rumple_index(las$X,las$Y,las$Z)

or using a CHM

las <- readLAS(i)
chm <- grid_canopy(las, 1, p2r())
ri  <- rumple_index(chm)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.