Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hexbin_metrics

Area-Based Approach in hexagonal cells.


Description

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. hexbin_metrics provides the opportunity to test something else. Refer to grid_metrics for more information.

Usage

hexbin_metrics(las, func, res = 20)

Arguments

las

An object of class LAS.

func

formula. An expression to be applied to each hexagonal cell.

res

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.

Value

A hexbin object from package hexbin or a list of hexbin objects if several metrics are returned.

See Also

Examples

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
lidar = readLAS(LASfile,filter = "-keep_random_fraction 0.5")

col = grDevices::colorRampPalette(c("blue", "cyan2", "yellow", "red"))

# Maximum elevation with a resolution of 8 m
hm = hexbin_metrics(lidar, ~max(Z), 8)
hexbin::plot(hm, colramp = col, main = "Max Z")

# Mean height with a resolution of 20 m
hm = hexbin_metrics(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 = hexbin_metrics(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")

lidR

Airborne LiDAR Data Manipulation and Visualization for Forestry Applications

v3.1.2
GPL-3
Authors
Jean-Romain Roussel [aut, cre, cph], David Auty [aut, ctb] (Reviews the documentation), Florian De Boissieu [ctb] (Fixed bugs and improved catalog features), Andrew Sánchez Meador [ctb] (Implemented wing2015() for segment_snags()), Bourdon Jean-François [ctb] (Contributed to Roussel2020() for track_sensor()), Gatziolis Demetrios [ctb] (Implemented Gatziolis2019() for track_sensor())
Initial release
2021-03-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.