This is a somewhat conceptual question about how the opt_output_files()
function works in lidR. I'm working on a project where I'm calculating a series of custom pixel metrics across a large spatial extent (using chunk processing of a LAScatalog) and unsure how to set things up to allow catalog files to be saved to disk without running into an overwrite issue due to them having the same name. I've tried two approaches for calculating metrics that ended up having equivalent outcomes:
1.
f=function(z) {
cvlad<-cv(LAD(z)$lad)
shan <-entropy(z)
mlad<-mean(LAD(z)$lad)
}
ladsite = pixel_metrics(ctg, ~f(Z), res = 5)
cvlad = pixel_metrics(ctg, ~as.numeric(cv(LAD(Z)$lad)), res = 5)
shan = pixel_metrics(ctg, ~as.numeric(entropy(Z)), res = 5)
mlad = pixel_metrics(ctg, ~as.numeric(mean(LAD(Z)$lad)), res = 5)
In both cases, each metric will calculate properly on its own but either overwrite the previous or return an error (depending on whether ctg@output_options$drivers$SpatRaster$param$overwrite <- TRUE
)
I have set the file output as: opt_output_files(ctg) <- paste0("F:/branching_data/analysis/temp", "/{XCENTER}_{YCENTER}_{ID}_1")
I recognize that this is never going to work the way I want it to since each raster file is necessarily going to have the same name as the one associated with the previous metric, so my question is just how to configure opt_output_files(ctg)
to allow for that (or whether I'm just going about this the wrong way somewhere else). I was able to get it to work as intended if I set opt_output_files(ctg)<-""
but ideally I would like to be able to store these on the disk in case I have large rasters in the future.