View source: R/check_inventory.R
| check_inventory | R Documentation |
This function checks whether a tree inventory data.frame is correctly formatted to be used as input for the ray-tracing model. It verifies the presence, type, and validity of mandatory and optional variables describing the geometry and attributes of trees within a forest stand.
check_inventory(trees_inv, verbose = TRUE)
trees_inv |
A data.frame with one row per tree and the following columns:
|
verbose |
Logical; if |
The function performs the following checks and validations:
Ensures trees_inv is a non-empty data.frame with all required columns.
Checks that id_tree values are unique.
Checks that either planar coordinates (x, y) or geographic coordinates
(lon, lat) are provided. If only lon and lat are supplied, they are converted to planar UTM coordinates in create_sl_stand().
The plot_inventory() function requires planar coordinates and cannot be used before this conversion.
Validates numeric columns (dbh_cm, h_m, hbase_m, rn_m, rs_m, re_m, rw_m) are numeric and non-negative.
Verifies that crown_type values are one of "E", "P", "2E", "8E", or "4P".
Ensures crown radii are present according to crown type.
Checks that hmax_m is provided when required and lies between hbase_m and h_m.
Ensures hbase_m < h_m.
Verifies that each tree has the crown LAD defined.
Provides informative error messages and warnings for all invalid conditions.
Invisibly returns TRUE if all checks pass.
# Using the example dataset from the package
data_prenovel <- SamsaRaLight::data_prenovel
trees <- data_prenovel$trees
# Check the inventory
check_inventory(trees)
# Quiet mode
check_inventory(trees, verbose = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.