# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las <- readLAS(LASfile)
# Cloud of points is voxelized with a 3-meter resolution and in each voxel
# the number of points is computed.
voxel_metrics(las, ~length(Z), 3)
# Cloud of points is voxelized with a 3-meter resolution and in each voxel
# the mean intensity of points is computed.
voxel_metrics(las, ~mean(Intensity), 3)
# Define your own metric function
myMetrics = function(i)
{
ret = list(
npoints = length(i),
imean = mean(i)
)
return(ret)
}
voxels <- voxel_metrics(las, ~myMetrics(Intensity), 3)
plot(voxels, color = "imean", trim = 100)
#etc.
attr(voxels, "res")
# }
Run the code above in your browser using DataLab