Skip to content

Commit 09a144c

Browse files
committed
calc_tcc_metrics() [WIP]
1 parent af09527 commit 09a144c

2 files changed

Lines changed: 81 additions & 64 deletions

File tree

R/calc_tcc_metrics.R

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
#' Predict plot-level canopy cover from individual tree measurements
22
#'
33
#' `calc_tcc_metrics()` computes plot-level predicted tree canopy cover (TCC)
4-
#' from tree list data. A full set of stand structure components used to derive
5-
#' the plot-level prediction are included in the output by default (see
4+
#' from tree list data. By default, a full set of stand structure components
5+
#' used to derive the plot-level TCC prediction are included in the output (see
66
#' Details).
77
#'
88
#' @details
9-
#' This function supports two alternative methods for predicting plot-level TCC.
10-
#'
11-
#' The default method requires individual tree coordinates to be provided in the
12-
#' input, as distance and azimuth from subplot centers for trees with diameter
13-
#' \verb{>= 5 in.} (12.7 cm), or from microplot centers for "sapling" trees with
14-
#' diameter \verb{>= 1 in.} (2.54 cm) but \verb{< 5 in.} (12.7 cm). This method
15-
#' involves spatially explicit stem-mapping to account for crown overlap of the
16-
#' mature trees, along with empirical modeling of the understory sapling
17-
#' contribution to total canopy cover (Toney et al. 2009). The empirical model
18-
#' for the sapling component also uses overstory tree point pattern as one of
19-
#' its predictor variables (based on Ripley's K function, Ripley 1977).
9+
#' This function provides two methods for predicting plot-level TCC.
10+
#'
11+
#' The default "stem-map" method requires individual tree coordinates to be
12+
#' included in the input as distance and azimuth from subplot centers for trees
13+
#' with diameter \verb{>= 5 in.} (12.7 cm), and from microplot centers for
14+
#' "saplings" having diameter \verb{>= 1 in.} (2.54 cm) but \verb{< 5 in.}
15+
#' (12.7 cm). This method involves mapping trees spatially to account for crown
16+
#' overlap, along with empirical modeling of the understory sapling contribution
17+
#' to total canopy cover (Toney et al. 2009). The empirical model for the
18+
#' sapling component also uses the overstory tree point pattern as a predictor
19+
#' variable (based on Ripley's K function, Ripley 1977).
2020
#'
2121
#' Alternatively, plot-level TCC can be predicted using a simplified approach
2222
#' that does not include exact stem placement (`stem_map = FALSE`). A random
2323
#' arrangement of stems is assumed in that case. This is the method used to
24-
#' estimate percent canopy cover in the Forest Vegetation Simulator (Crookston
25-
#' and Stage 1999).
24+
#' estimate tree canopy cover in the Forest Vegetation Simulator (Crookston and
25+
#' Stage 1999).
2626
#'
27-
#' The stem-map method requires computation of several stand structure metrics
28-
#' which are components of the overall model used to derive the plot-level TCC
29-
#' estimate. These include:
27+
#' Both methods require estimates of individual tree crown width, which are
28+
#' computed with `calc_crwidth()` if not provided in the input tree list.
29+
#'
30+
#' The stem-map method also requires computation of several stand structure
31+
#' metrics, which are components of the overall model used to derive a
32+
#' plot-level TCC estimate. These additional variables include:
3033
#'
31-
#' * individual tree crown widths via `calc_crwidth()` (if not provided in the
32-
#' input tree list)
3334
#' * individual subplot and microplot crown overlays via `calc_crown_overlay()`
3435
#' * a stand height metric (`meanTreeHtBAW`) via `calc_ht_metrics()`
3536
#' * plot-level counts of mature trees and saplings
36-
#' * descriptive statistics for the tree spatial point pattern via
37+
#' * descriptive spatial statistics for the overstory tree point pattern via
3738
#' `create_fia_ppp() |> spatstat.explore::Lest()`
3839
#'
3940
#'
@@ -46,7 +47,10 @@
4647
#' the input data frame will have the columns specified in
4748
#' [DEFAULT_TREE_COLUMNS] (see `?DEFAULT_TREE_COLUMNS`). Potentially, only a
4849
#' subset of those columns will be needed depending on values given for the
49-
#' arguments `stem_map`, `full_output` and `crwidth_col` described below.
50+
#' arguments `stem_map` and `full_output` described below. If the input data
51+
#' frame has a column named `"CRWIDTH"` it will be used for tree crown width
52+
#' values, otherwise, crown widths will be calculated with a call to
53+
#' `calc_crwidth()`.
5054
#' @param stem_map A logical value indicating whether to map individual trees
5155
#' explicitly using coordinates specified in terms of distance and azimuth from
5256
#' subplot/microplot centers. The default is `TRUE`, in which case the input
@@ -59,11 +63,6 @@
5963
#' output list includes subplot-level TCC estimates, live tree and sapling
6064
#' counts, stand height metrics, and point pattern statistics, depending on the
6165
#' value given for `stem_map` (see Details).
62-
#' @param crwidth_col The name of a column in `tree_list` containing the
63-
#' individual tree crown widths (case-sensitive). Defaults to `"CRWIDTH"`. If
64-
#' the given column name does not exist in the input data frame, or this
65-
#' argument is set to `NULL`, then crown widths will be computed with a call to
66-
#' `calc_crwidth()`.
6766
#' @param digits Optional integer indicating the number of digits to keep in the
6867
#' return values (defaults to `1`). May be passed to `calc_crwidth()` and
6968
#' `calc_ht_metrics()`.
@@ -85,7 +84,7 @@
8584
#' Statistical Society: Series B (Methodological)_, 39(2): 172–192.
8685
#' \url{https://doi.org/10.1111/j.2517-6161.1977.tb01615.x}.
8786
#'
88-
#' Toney, C, J.D. Shaw and M.D. Nelson. 2009. A stem-map model for predicting
87+
#' Toney, C., J.D. Shaw and M.D. Nelson. 2009. A stem-map model for predicting
8988
#' tree canopy cover of Forest Inventory and Analysis (FIA) plots. In:
9089
#' McWilliams, Will; Moisen, Gretchen; Czaplewski, Ray, comps. _Forest Inventory
9190
#' and Analysis (FIA) Symposium 2008_; October 21-23, 2008; Park City, UT. Proc.
@@ -98,10 +97,36 @@
9897
#' [create_fia_ppp()]
9998
#'
10099
calc_tcc_metrics <- function(tree_list, stem_map = TRUE, full_output = TRUE,
101-
crwidth_col = "CRWIDTH", digits = 1) {
100+
digits = 1) {
101+
102+
if (!(is.logical(stem_map) && length(stem_map) == 1))
103+
stop("'stem_map' must be a single logical value", call. = FALSE)
104+
105+
if (!(is.logical(full_output) && length(full_output) == 1))
106+
stop("'full_output' must be a single logical value", call. = FALSE)
107+
108+
X <- NULL # spatstat point pattern object
109+
if (stem_map) {
110+
# validate the input tree list for stem-mapping and get X
111+
X <- create_fia_ppp(tree_list)
112+
}
102113

114+
ht_metrics <- NULL
115+
if (stem_map || full_output) {
116+
# validate the input tree list for stand height calc and get metrics
117+
ht_metrics <- calc_ht_metrics()
118+
}
103119

120+
if (!("CRWIDTH" %in% colnames(tree_list)))
121+
tree_list$CRWIDTH <- calc_crwidth(tree_list)
104122

105123

124+
# estimate of the L-function (Besag's transformation of Ripley's K) for
125+
# r = 0:12 feet
126+
if (stem_map) {
127+
L <- spatstat.explore::Lest(X, r = 0:12)
128+
# mean of L at r = 6, 8, 10, 12 ft (Ripley's isotropic edge correction)
129+
L_mean <- mean(L$iso[c(7, 9, 11, 13)])
130+
}
106131

107132
}

man/calc_tcc_metrics.Rd

Lines changed: 27 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)