get_gaps_fbhs {LadderFuelsR}R Documentation

Gaps and Fuel layers Base Height (FBH)

Description

This function calculates gaps and fuel layers base height (FBH) as the difference in percentiles between consecutive LAD values along the vertical tree profile (VTP). Negative differences are linked to gaps and positive differences to fuel base height.

Usage

get_gaps_fbhs (LAD_profiles, step=1, min_height=1.5,
perc_gap= 25, perc_base= 25, verbose=TRUE)

Arguments

LAD_profiles

original tree Leaf Area Density (LAD) profile (output of [lad.profile()] function in the leafR package. An object of the class text.

step

Numeric value for the actual height bin step (in meters).

min_height

Numeric value for the actual minimum base height (in meters).

perc_gap

Numeric value of the percentile threshold used to identify gaps (default percentile 25th).

perc_base

Numeric value of the percentile threshold used to identify fuels layers base height (default percentile 25th).

verbose

Logical, indicating whether to display informational messages (default is TRUE).

Details

# List of tree metrics:

Value

A data frame giving the height of gaps and fuel layers bases in meters.

Author(s)

Olga Viedma, Carlos Silva, JM Moreno and A.T. Hudak

Examples

library(magrittr)
library(dplyr)

# LAD profiles derived from normalized ALS data after applying [lad.profile()] function
LAD_profiles <- read.table(system.file("extdata", "LAD_profiles.txt", package = "LadderFuelsR"),
header = TRUE)
LAD_profiles$treeID <- factor(LAD_profiles$treeID)

trees_name1 <- as.character(LAD_profiles$treeID)
trees_name2 <- factor(unique(trees_name1))

metrics_precentile_list1<-list()

for (i in levels(trees_name2)) {
tree1 <- LAD_profiles |> dplyr::filter(treeID == i)
metrics_precentil <- get_gaps_fbhs(tree1, step=1,
min_height=1.5,
perc_gap= 25,perc_base= 25,
verbose=TRUE)
metrics_precentile_list1[[i]] <- metrics_precentil
}

metrics_all_percentil <- dplyr::bind_rows(metrics_precentile_list1)
metrics_all_percentil$treeID <- factor(metrics_all_percentil$treeID)

# Remove the row with all NA values from the original data frame
# First remove "treeID" and "treeID1" columns
no_treeID <- metrics_all_percentil[, -which(names(metrics_all_percentil) == c("treeID","treeID1"))]

# Check if any row has all NA values
NA_or_zero <- apply(no_treeID, 1, function(row) all(is.na(row) | row == 0))

# Get the row index with all NA values
row_index <- which(NA_or_zero)

# Remove the row with all NA values from the original data frame
if (length(row_index) > 0) {
gap_cbh_metrics <- metrics_all_percentil[-row_index, ]
} else {
gap_cbh_metrics <- metrics_all_percentil
}

[Package LadderFuelsR version 0.0.6 Index]