# NOT RUN {
LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las = readLAS(LASfile, filter = "-drop_z_below 0")
# NOTE: This dataset is already segmented
# plot(las, color = "treeID", colorPalette = pastel.colors(200))
# Default computes only Z max
metrics = tree_metrics(las)
# User-defined metrics - mean height and mean intensity for each tree
metrics = tree_metrics(las, ~list(Zmean = mean(Z), Imean = mean(Intensity)))
# Define your own new metrics function
myMetrics = function(z, i)
{
metrics = list(
imean = mean(i),
imax = max(i),
npoint = length(z)
)
return(metrics)
}
metrics = tree_metrics(las, ~myMetrics(Z, Intensity))
# predefined metrics (see ?stdmetrics)
metrics = tree_metrics(las, .stdtreemetrics)
# }
Run the code above in your browser using DataLab