Skip to content

feat(tree-metrics): implement SNFI tree-level metrics and competition indices - #27

Open
aitorvv wants to merge 5 commits into
mainfrom
avv-snfi-tree-functions
Open

feat(tree-metrics): implement SNFI tree-level metrics and competition indices#27
aitorvv wants to merge 5 commits into
mainfrom
avv-snfi-tree-functions

Conversation

@aitorvv

@aitorvv aitorvv commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

  • Implements tree-level functions adapted from SNFI support scripts:
    • silv_tree_expansion_factor(): Dynamic expansion factors for fixed area or concentric SNFI plots (radii 5, 10, 15, 25 m).
    • silv_tree_bal() & silv_tree_bas(): Basal Area in Larger/Smaller trees competition indices per plot.
    • silv_tree_crown_ratio(): Tree crown ratio calculation.
    • silv_tree_coordinates(): Tree Cartesian coordinates from distance and azimuth.
    • silv_tree_circumference(), silv_tree_mean_dbh(), silv_tree_slenderness().
  • Full Roxygen2 documentation with examples and registered in _pkgdown.yml.
  • Added unit tests in tests/testthat/test-tree-level.R.

Note: This PR follows after PR #26.

Verification

devtools::load_all()

# 1. Verify dynamic SNFI expansion factors
dbh_vec <- c(10, 18, 30, 50)
exp_vec <- silv_tree_expansion_factor(type = "snfi", diameter = dbh_vec)
stopifnot(all.equal(round(exp_vec, 2), c(127.32, 31.83, 14.15, 5.09)))

# 2. Verify BAL and BAS competition indices
df_bal <- inventory_samples |> dplyr::filter(plot_id == 8)
bal_vals <- silv_tree_bal(df_bal, plot_id = plot_id, tree_id = tree_id, diameter = diameter, plot_size = 10)
stopifnot(is.numeric(bal_vals), length(bal_vals) == nrow(df_bal))

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