| plot_metrics {lidR} | R Documentation |
Computes metrics for each plot of a ground inventory by 1. clipping the plots inventories, 2. computing a user's metrics to each plot, and 3. combining spatial data and metrics into one data.frame ready for statistical modelling. 'plot_metrics' is basically a seamless wrapper around clip_roi, cloud_metrics, 'cbind' and adequate processing settings.
plot_metrics(las, func, geometry, ...)
las |
An object of class LAS or LAScatalog. |
func |
formula. An expression to be applied to each cell (see also grid_metrics). |
geometry |
a spatial object. Many types are supported (see also clip_roi) |
... |
optional supplementary options (see also clip_roi) |
An 'sp' or 'sf' object depending on the input with all the metrics for each plot bound with the original input.
LAScatalogThis section appears in each function that supports a LAScatalog as input.
In lidR when the input of a function is a LAScatalog the
function uses the LAScatalog processing engine. The user can modify the engine options using
the available options. A careful reading of the
engine documentation is recommended before processing LAScatalogs. Each
lidR function should come with a section that documents the supported engine options.
The LAScatalog engine supports .lax files that significantly improve the computation
speed of spatial queries using a spatial index. Users should really take advantage a .lax files,
but this is not mandatory.
Supported processing options for a LAScatalog in plot_metrics function (in bold). For
more details see the LAScatalog engine documentation:
chunk size: Not relevant here.
chunk buffer: Not relevant here.
chunk alignment: Not relevant here.
progress: Displays a progress estimate.
output files: plots are extracted in memory.
select: Read only the attributes of interest.
filter: Read only the points of interest.
Other metrics:
cloud_metrics(),
grid_metrics(),
point_metrics(),
tree_metrics(),
voxel_metrics()
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
SHPfile <- system.file("extdata", "efi_plot.shp", package="lidR")
las <- readLAS(LASfile)
inventory <- sf::st_read(SHPfile, quiet = TRUE)
inventory # contains an ID and a Value Of Interest (VOI) per plot
M <- plot_metrics(las, ~list(q85 = quantile(Z, probs = 0.85)), inventory, radius = 11.28)
model <- lm(VOI ~ q85, M)
M <- plot_metrics(las, .stdmetrics_z, inventory, radius = 11.28)
## Not run:
# Works with polygons as well
inventory <- sf::st_buffer(inventory, 11.28)
plot(las@header)
plot(sf::st_geometry(inventory), add = TRUE)
M <- plot_metrics(las, .stdmetrics_z, inventory)
## End(Not run)