get_distance {LadderFuelsR}R Documentation

Distances between fuel layers

Description

This function calculates distances (and their heights) between fuel layers as the difference between consecutive gaps and fuel bases (the gap height always must be lower than the fuel base height).

Usage

get_distance (gap_cbh_metrics,gaps_perc,step=1,min_height=1.5,verbose=TRUE)

Arguments

gap_cbh_metrics

data frame with gaps (distances) and fuel base heights (output of [get_gaps_fbhs()] function). An object of the class text.

gaps_perc

data frame with Leaf Area Density (LAD) percentiles for each height values (output of [calculate_gaps_perc()] function). 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).

verbose

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

Details

# List of tree metrics:

Value

A data frame giving distances (and their heights) between fuel layers in meters.

Author(s)

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

See Also

get_gaps_fbhs

calculate_gaps_perc

Examples

library(magrittr)
library(gdata)
library(dplyr)

# Before running this example, make sure to run get_gaps_fbhs().
if (interactive()) {
gap_cbh_metrics <- get_gaps_fbhs()
LadderFuelsR::gap_cbh_metrics$treeID <- factor(LadderFuelsR::gap_cbh_metrics$treeID)

# Before running this example, make sure to run calculate_gaps_perc().
LadderFuelsR::gaps_perc$treeID <- factor(LadderFuelsR::gaps_perc$treeID)

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

metrics_distance_list <- list()

for (i in levels(trees_name2)) {

# Filter data for each tree
tree1 <- gap_cbh_metrics |> dplyr::filter(treeID == i)
tree2 <- gaps_perc |> dplyr::filter(treeID == i)
# Get distance metrics for each tree
metrics_distance <- get_distance(tree1, tree2, step=1, min_height=1.5)
metrics_distance_list[[i]] <- metrics_distance
}
# Combine the individual data frames
distance_metrics <- dplyr::bind_rows(metrics_distance_list)
}

[Package LadderFuelsR version 0.0.6 Index]