Learn R Programming

lidR (version 1.2.1)

grid_metrics3d: Voxelize the space and compute metrics for each voxel

Description

Voxelize the cloud of points and compute a series of descriptive statistics for each voxel.

Usage

grid_metrics3d(.las, func, res = 1, debug = FALSE)

Arguments

.las

An object of class LAS

func

the function to be apply to each voxel.

res

numeric. The size of the voxels

debug

logical. If you encounter a non trivial error try debug = TRUE.

Value

It returns a data.table containing the metrics for each voxel. The table has the class lasmetrics3d enabling easier plotting.

Details

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).

See Also

grid_metrics

Examples

Run this code
# 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