
Voxelize the cloud of points and compute a series of descriptive statistics for each voxel.
grid_metrics3d(.las, func, res = 1, debug = FALSE)
An object of class LAS
the function to be apply to each voxel.
numeric. The size of the voxels
logical. If you encounter a non trivial error try debug = TRUE
.
It returns a data.table
containing the metrics for each voxel. The table
has the class lasmetrics3d
enabling easier plotting.
Voxelize creates a 3D matrix of voxels with a given resolution. It creates a voxel from the cloud of points if there is at least one point in the voxel. For each voxel the function allows computation of one or several derived metrics in the same way as the grid_metrics functions. Basically there are no predefined metrics. Users must write their own function to create metrics. Voxelize will dispatch the LiDAR data for each voxel in the user's function. The user writes their function without considering voxels, only a cloud of points (see example).
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile)
# Cloud of points is voxelized with a 3-meter resolution and in each voxel
# the number of points is computed.
grid_metrics3d(lidar, length(Z), 3)
# Cloud of points is voxelized with a 3-meter resolution and in each voxel
# the mean scan angle of points is computed.
grid_metrics3d(lidar, mean(ScanAngle), 3)
# }
# NOT RUN {
# Define your own metric function
myMetrics = function(i, angle)
{
ret = list(
npoints = length(i),
angle = mean(angle),
imean = mean(i)
)
return(ret)
}
voxels = grid_metrics3d(lidar, myMetrics(Intensity, ScanAngle), 3)
plot(voxels, color = "angle")
plot(voxels, color = "imean")
#etc.
# }
Run the code above in your browser using DataLab