Would it be possible to calculate a density metric in height intervals as in FUSION or Lastools?
e.g number of all returns between 0.2 and 3 meters/number of total returns in 1 meters cell.
I'm trying to compute using the function of the package stdmetrics_z(z)
but I had an error with fast_table
myMetrics2 = function (z) {
n = length(z)
zmax = max(z)
zmean = mean(z)
if (zmax <= 0) {
d = rep(0, 9)
}
else {
breaks = seq(0.2, 25, 2.8)
d = findInterval(z, breaks)
d = fast_table(d, 10)
d = d/sum(d) * 100
d = cumsum(d)[1:9]
d = as.list(d)
}
names(d) = paste0("zpcum", 1:9)
metrics = c( d)
return(metrics)
}
metric2=grid_metrics(ctgn.i, ~myMetrics2(z, res=1)
#> Processing [=========================================] 100% (1/1) eta: 0s
#> Error: could not find function "fast_table"
fast_table
is an internal function of the lidR package. You took the source code of the package and put it in the your global environment. You cannot expect this to work.