Here is my code :
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg = readLAScatalog(LASfile)
myMetrics2 <- function(rnu, nor) {
tab <- table(rnu, nor)
return(tab)
}
g <- function(chunk) {
las <- readLAS(chunk)
if (is.empty(las)) {
return(NULL)
}
metrics <- cloud_metrics(las, myMetrics2(ReturnNumber, NumberOfReturns))
return(metrics)
}
opt_progress(ctg) <- FALSE
opt_chunk_buffer(ctg) <- 0
opt_chunk_size(ctg) <- 0
opt_output_files(ctg) <- ""
p_metrics <- catalog_apply(ctg, g)
It generate this error :
Error: Duplicated elements found. At least one of the metrics was not a number. Each metric should be a single number.
I don't understand why ?