branch_size_distribution: Get Branch size distribution from a QSM

View source: R/traits_from_qsm.R

branch_size_distributionR Documentation

Get Branch size distribution from a QSM

Description

This function outputs the volume (in mL) distribution of branches across different branch diameter classes (in cm). Outputs a table that can be used in other functions to find branch_skewness or branch_volume_weighted_stats()

Usage

branch_size_distribution(qsm, breaks = NULL, plot = TRUE)

Arguments

qsm

– a QSM loaded using '[load_qsm()]'.

breaks

numeric – a vector of diameter classes (in cm) by which to summarize branch volume. If 'NULL' the branch of branch sizes will be distributed across 1 cm bins.

plot

boolean – indicates whether the branch diameter distribution should be plotted as a histogram.

Value

A tibble summarizing branch volume by diameter class with columns:

diameter_cm

Factor indicating the diameter class (cm).

midpoint

Numeric midpoint (cm) of each diameter class.

volume_mL

Total branch volume (mL) within the class.

Returns 'NA' if fewer than two branch cylinders are present.

Examples

qsm_file = system.file("extdata", "tree_0744_qsm.txt", package='tReeTraits')
qsm = load_qsm(qsm_file)
branch_distribution = branch_size_distribution(qsm, plot=TRUE)
print(branch_distribution)

#volume-weighted mean
branch_volume_weighted_stats(qsm, FUN = function(x) mean(x))

#volume-weighted median
branch_volume_weighted_stats(qsm, FUN = function(x) median(x))

# volume-weighted skewness
branch_volume_weighted_stats(qsm, FUN = function(x) 3*(mean(x) - median(x)) / sd(x))

tReeTraits documentation built on Feb. 26, 2026, 1:07 a.m.