Computes a series of descriptive statistics for a LiDAR dataset within hexagonal cells.
This function is identical to grid_metrics but with hexagonal cells instead of
square pixels. After all, we conduct circular plot inventories and we map models on pixel-based maps.
grid_hexametrics
provides the opportunity to test something else. Refer to grid_metrics
for more information.
grid_hexametrics(las, func, res = 20)
An object of class LAS
.
formula. An expression to be applied to each hexagonal cell.
numeric. To be consistent with grid_metrics, the square of res
give the area
of the hexagonal cells, like in grid_metrics
. The difference being the fact that for square pixels this
is obvious. Here res = 20
gives 400-square-meter hexagonal cells.
A hexbin object from package hexbin
or a list
of
hexbin
objects if several metrics are returned.
# NOT RUN {
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile)
col = grDevices::colorRampPalette(c("blue", "cyan2", "yellow", "red"))
# Maximum elevation with a resolution of 8 m
hm = grid_hexametrics(lidar, ~max(Z), 8)
hexbin::plot(hm, colramp = col, main = "Max Z")
# Mean height with a resolution of 20 m
hm = grid_hexametrics(lidar, ~mean(Z), 20)
hexbin::plot(hm, colramp = col, main = "Mean Z")
# 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)
hexbin::plot(metrics$zwimean, colramp = col, main = "zwimean")
hexbin::plot(metrics$zimean, colramp = col, main = "zimean")
hexbin::plot(metrics$zsqmean, colramp = col, main = "zsqmean")
# }
Run the code above in your browser using DataLab