Last chance! 50% off unlimited learning
Sale ends in
Computes a series of descriptive statistics for a LiDAR dataset within hexagonal cells from a hexagonal grid pattern. This function is identical to grid_metrics or grid_metrics3d or tree_metrics but with hexagonal cells instead of classical square pixels. Please refer to grid_metrics for more information.
grid_hexametrics(.las, func, res = 20, splitlines = FALSE, debug = FALSE)
An object of class LAS
the function to be applied to each hexagonal cell
numeric. The inscribed circle radius of a hexagon. Default = 20.
logical. If TRUE the algorithm will compute the metrics for each flightline individually. It returns the same cells several times in overlaps.
logical. If you encounter a non trivial error try debug = TRUE
.
It returns a data.table
containing the metrics for each hexagonal cell. The table
has the class "lashexametrics" enabling easy plotting.
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile)
# Maximum elevation with a resolution of 4 m
grid_hexametrics(lidar, max(Z), 4) %>% plot
# Mean height with a resolution of 20 m
grid_hexametrics(lidar, mean(Z)) %>% plot
# Define your own new metrics
myMetrics = function(z, i)
{
metrics = list(
zwimean = sum(z*i)/sum(i), # Mean elevation weighted by intensities
zimean = mean(z*i), # Mean products of z by intensity
zsqmean = sqrt(mean(z^2)) # Quadratic mean
)
return(metrics)
}
metrics = grid_hexametrics(lidar, myMetrics(Z, Intensity), 10)
plot(metrics, "zwimean")
plot(metrics, "zimean")
plot(metrics, "zsqmean")
#etc.
# }
Run the code above in your browser using DataLab