voxel_metrics
does not have a version for LAScatalog
. The reason is that the output is a data.frame
. Unlike spatial objects like sf
, SpatRaster
or LAS
a data.frame
can contain anything. It is thus impossible to let the LAScatalog
processing engine automatically handle the logic of a function returning a data.frame
.
You could convert it into sf
with PointZ
geometries and record it into geopackage files. This would looks like this
opt_output_files(ctg) = "/path/file/to/export_{ID}"
opt_chunk_buffer(ctg) = 10
ctg@output_options$drivers$sf$extension = ".gpkg"
apply_vm = function(las)
{
m = voxel_metrics(las, 8, ~mean(Intensity))
m = sf::st_as_sf(m, coords = c("X", "Y", "Z"))
}
res = catalog_map(ctg, apply_vm)
If your dataset if small enough, you can remove opt_output_files(ctg)
to return everything in R as one big sf
object.
You are free to find another solution that fits your need. This is just a quick solution I can offer right now.