# A small extracted Level 2B table
level2BVPM <- data.table::data.table(
pai = c(1.1, 1.8, 2.2, 0.9, 1.5, 2.4),
cover = c(0.31, 0.44, 0.52, 0.27, 0.39, 0.58),
poly_id = rep(c("stand_1", "stand_2"), each = 3)
)
head(level2BVPM)
# Define your own function
mySetOfMetrics <- function(x) {
metrics <- list(
min = min(x), # Min of x
max = max(x), # Max of x
mean = mean(x), # Mean of x
sd = sd(x) # Sd of x
)
return(metrics)
}
# Computing the max of the Total Plant Area Index
pai_max <- polyStatsLevel2BVPM(level2BVPM, func = max(pai), id = NULL)
pai_max
# Computing the max of the Total Plant Area Index stratified by polygon
pai_max_poly <- polyStatsLevel2BVPM(level2BVPM, func = max(pai), id = "poly_id")
head(pai_max_poly)
# Computing the serie of statistics of canopy cover stratified by polygon
cover_metrics <- polyStatsLevel2BVPM(level2BVPM,
func = mySetOfMetrics(cover),
id = "poly_id"
)
head(cover_metrics)
Run the code above in your browser using DataLab