add_forests {medfateland} | R Documentation |
Add forests
Description
Creates and adds forest data to an sf
object by reading from tree and shrub data tables
Usage
add_forests(
x,
tree_table = NULL,
tree_mapping = NULL,
shrub_table = NULL,
shrub_mapping = NULL,
merge_trees = TRUE,
merge_shrubs = TRUE,
SpParams = NULL,
progress = FALSE
)
Arguments
x |
An object of class |
tree_table |
A data frame with tree records in rows and attributes in columns. Tree records can correspond to individual trees or groups of trees with an associated density. |
tree_mapping |
A named character vector to specify mappings of columns in
|
shrub_table |
A data frame with shrub records in rows and attributes in columns. Records can correspond to individual shrubs (with crown dimensions and height) or groups of shrubs with an associated cover estimate. |
shrub_mapping |
A named character vector to specify mappings of columns in
|
merge_trees |
A logical flag to simplify tree cohorts by merging tree records in DBH classes (see |
merge_shrubs |
A logical flag to simplify shrub cohorts by merging shrub records in height classes (see |
SpParams |
A data frame with species parameters (see |
progress |
A logical flag to include a progress bar while processing the data. |
Details
The current implementation will replace existing forests of the indicated 'id' values.
Value
A modified object of class sf
with column 'forest'.
Author(s)
Miquel De Cáceres Ainsa, CREAF
See Also
impute_forests()
, forest_mapWoodyTables
, forest_mergeTrees
Examples
# Load tree data
data(poblet_trees)
# Load species parameters
data(SpParamsMED)
# Define sf with three stands
cc <- rbind(c(1.0215, 41.3432),
c(1.0219, 41.3443),
c(1.0219, 41.3443))
d <- data.frame(lon = cc[,1], lat = cc[,2],
id = c("POBL_CTL", "POBL_THI_BEF", "POBL_THI_AFT"))
x <- sf::st_as_sf(d, coords = c("lon", "lat"), crs = 4326)
x
# Define tree mapping
mapping <- c("id" = "Plot.Code", "Species.name" = "Species", "DBH" = "Diameter.cm")
# Read tree data (warnings are raised)
y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED)
# Correct scientific name for downy oak and repeat to avoid losing tree records
poblet_trees$Species[poblet_trees$Species=="Quercus humilis"] <- "Quercus pubescens"
y_1 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED)
# Display summary of first forest
summary(y_1$forest[[1]], SpParamsMED)
# Add sampled plot surface and repeat reading to correct tree density
poblet_trees$PlotSurface <- 706.86
mapping <- c(mapping, "plot.size" = "PlotSurface")
y_2 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED)
summary(y_2$forest[[1]], SpParamsMED)
# Check forests (height is missing!)
check_forests(y_2)
# Estimate tree height using general allometric
poblet_trees$Height.cm <- 100 * 1.806*poblet_trees$Diameter.cm^0.518
#Modify mapping to include height and repeat
mapping <- c(mapping, "Height" = "Height.cm")
y_3 <- add_forests(x, tree_table = poblet_trees, tree_mapping = mapping, SpParams = SpParamsMED)
summary(y_3$forest[[1]], SpParamsMED)
# Final check
check_forests(y_3)