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