I'm using catalog_apply with a las catalog to compute some simple cloud metrics, which returns a list.
The following code, for example, will process 45 point clouds and return a list of 45 items. But how do I relate the values in the list to their respective plot IDs? Is it possible to keep track of the file name with catalog apply?
# read catalog
ctg <- readLAScatalog(here())
# define function for catalog apply
my_func <- function(chunk)
{
las <- readLAS(chunk)
if (is.empty(las)) return(NULL)
metrics <- cloud_metrics(las, ~max(Z)) # calculate max Z
return(metrics)
}
# set options --------------------------
plan(strategy = multisession, workers = 12)
opt_independent_files(ctg) <- TRUE
# run function
(max_z <- catalog_apply(ctg, my_func))