Skip to content

feat(summary): implement silv_tree_summary with integrated predictions, SNFI plots, and stand volume/biomass/carbon - #29

Open
aitorvv wants to merge 7 commits into
mainfrom
avv-tree-summary
Open

feat(summary): implement silv_tree_summary with integrated predictions, SNFI plots, and stand volume/biomass/carbon#29
aitorvv wants to merge 7 commits into
mainfrom
avv-tree-summary

Conversation

@aitorvv

@aitorvv aitorvv commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

  • Implements silv_tree_summary():
    • Computes tree class (dclass), tree basal area (g), expansion factor (expan), expanded basal area (g_ha), tree slenderness, and competition indices (bal, bas).
    • Supports integrated on-the-fly predictions for volume (vcc, vsc, iavc), biomass (biomass), and carbon (carbon).
  • Adds support for concentric Spanish National Forest Inventory plots (plot_shape = "snfi").
  • Extends silv_summary() to calculate and aggregate stand volume (v_ha in $m^3/\text{ha}$), biomass (w_ha in $t/\text{ha}$), and carbon (c_ha in $t/\text{ha}$).
  • Extends silv_summary_species() (V_sp1, W_sp1, C_sp1) and silv_summary_mortality() (V_alive/V_dead, W_alive/W_dead, C_alive/C_dead).
  • Added unit tests in tests/testthat/test-tree-summary.R and tests/testthat/test-summary-thinning.R.
  • Registered silv_tree_summary in _pkgdown.yml.

Note: This PR builds on top of avv-snfi-stand-functions.

Verification

devtools::load_all()

# 1. Verify tree summary with SNFI concentric rings and predictions
df_tree <- inventory_samples |> dplyr::filter(plot_id == 8) |> dplyr::mutate(province = 1)
res_tree <- silv_tree_summary(
  df_tree, diameter, height, plot_id, species, province = province,
  plot_shape = "snfi", compute_bal = TRUE,
  predict_volume = TRUE, predict_biomass = TRUE, predict_carbon = TRUE
)
stopifnot(all(c("dclass", "g", "expan", "g_ha", "slenderness", "bal", "bas", "vcc", "biomass", "carbon") %in% names(res_tree)))

# 2. Verify stand summary with volume (m3/ha), biomass (t/ha), carbon (t/ha)
res_stand <- silv_summary(
  df_tree |> dplyr::filter(species == 28), diameter, height,
  plot_shape = "snfi", .groups = "plot_id", species = species, province = province,
  predict_volume = TRUE, predict_biomass = TRUE, predict_carbon = TRUE
)
gm <- res_stand@group_metrics
stopifnot(all(c("ntrees_ha", "g_ha", "v_ha", "w_ha", "c_ha", "slenderness") %in% names(gm)))
stopifnot(gm$v_ha > 0, gm$w_ha > 0, gm$c_ha > 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants