Learn R Programming

LadderFuelsR (version 0.0.6)

get_real_depths: Effective fuel layers depth

Description

This function recalculates fuel layers depth after considering distances greater than the actual height bin step.

Usage

get_real_depths (effective_fbh, step=1, min_height=1.5, verbose=TRUE)

Value

A data frame giving new fuel layers depth after considering distances greater than the actual height bin step.

Arguments

effective_fbh

tree metrics with the recalculated base height of fuel layers after considering distances greater than any number of height bin steps (output of [get_real_fbh()] 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).

Author

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

Details

# List of tree metrics:

  • treeID: tree ID with strings and numeric values

  • treeID1: tree ID with only numeric values

  • dist: Distance between consecutive fuel layers (m)

  • Hdist - Height of the distance between consecutive fuel layers (m)

  • Hcbh - Base height of each fuel separated by a distance greater than the certain number of steps

  • dptf - Depth of fuel layers (m) after considering distances greater than the actual height bin step

  • Hdptf - Height of the depth of fuel layers (m) after considering distances greater than the actual height bin step

  • max_height - Maximum height of the tree profile

See Also

get_renamed0_df

get_real_fbh

Examples

Run this code
library(magrittr)
library(tidyr)
library(dplyr)

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

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

depth_metrics_corr_list <- list()

for (i in levels(trees_name2)){
# Filter data for each tree
tree3 <- effective_fbh |> dplyr::filter(treeID == i)
# Get real depths for each tree
depth_metrics_corr <- get_real_depths(tree3, step=1, min_height=1.5,verbose=TRUE)
depth_metrics_corr_list[[i]] <- depth_metrics_corr
}

# Combine depth values for all trees
effective_depth <- dplyr::bind_rows(depth_metrics_corr_list)

# Reorder columns
original_column_names <- colnames(effective_depth)

# Specify prefixes
desired_order <- c("treeID", "Hcbh", "dptf", "dist", "Hdist", "Hdptf", "max_height")

# Identify unique prefixes
prefixes <- unique(sub("^([a-zA-Z]+).*", "\\1", original_column_names))
# Initialize vector to store new order
new_order <- c()

# Loop over desired order of prefixes
for (prefix in desired_order) {
  # Find column names matching the current prefix
  matching_columns <- grep(paste0("^", prefix), original_column_names, value = TRUE)
  # Append to the new order
  new_order <- c(new_order, matching_columns)
}
effective_depth <- effective_depth[, new_order]
}

Run the code above in your browser using DataLab