```
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile)
# Cloud of points is voxelized with a 1-meter resolution and in each voxel
# the number of points is computed.
grid_metrics3d(lidar, length(Z))
# Cloud of points is voxelized with a 1-meter resolution and in each voxel
# the mean scan angle of points is computed.
grid_metrics3d(lidar, mean(ScanAngle))
# Define your own metric function
myMetrics = function(i, angle, pulseID)
{
ret = list(
npulse = length(unique(pulseID)),
angle = mean(angle),
imean = mean(i)
)
return(ret)
}
voxels = grid_metrics3d(lidar, myMetrics(Intensity, ScanAngle, pulseID))
plot(voxels, "angle")
plot(voxels, "imean")
#etc.
# }
```

Run the code above in your browser using DataLab