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?