The following are some examples of R scripts used to perform Calculations

-----------------------------------------------------------------------------------------------

Calculation name: Tree - Basal area

Calculation type: R script

tree$basal_area <- with(tree, pi * (0.01*dbh/2)^2)

-----------------------------------------------------------------------------------------------

Calculation name: Tree - Volume

Calculation type: R script

# Basic form factor volume model

tree$volume <- with( tree, (0.1291+1.5984 * ff) * pi * (0.01 * dbh / 2)^2 * est_height^0.764 );

-----------------------------------------------------------------------------------------------

Calculation name: Stand - IPCC class

Calculation type: Category

# '1' Forest land, '2' Grass land, '3' Cropland, '4' Settlements, '5' Wetland, '-1' NA

stand$ipcc_class = with ( stand,

ifelse(forest_status ==160 | forest_status == 630, 5,

ifelse(forest_status < 440, 1,

ifelse(forest_status == 440, 2,

ifelse(forest_status < 600, 3, 4)

-----------------------------------------------------------------------------------------------

Calculation name: Tree - AG Biomass

Calculation type: R script

tree$genus_code <- substr( tree$species_code, 1, 3 ); # compute AGB in kg

tree$aboveground_biomass <- with ( tree,

ifelse( genus_code=='PIN', BEF_pinus * volume * 500, # Pinus, wood density = 500 kg/m3

269.63396 * (((dbh/100)^2*est_height)^0.95193) # Evergreen forest

tree$aboveground_biomass <- tree$aboveground_biomass / 1000

-----------------------------------------------------------------------------------------------

Calculation name: Tree - BG Biomass

Calculation type: R script

# conversion factor source:

tree$belowground_biomass <- tree$aboveground_biomass * 0.265;

-----------------------------------------------------------------------------------------------

Calculation name: Tree - Total biomass

Calculation type: R script

tree$total_biomass <- tree$aboveground_biomass + tree$belowground_biomass ;

-----------------------------------------------------------------------------------------------

Calculation name: Stump - Count

Calculation type: R script

stump$quantity[is.na(stump$quantity)] <- 1

stump$quantity[stump$quantity ==''] <- 1

stump$count_stump <- stump$quantity

-----------------------------------------------------------------------------------------------