knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The goal of treeco
is to provide R users a tool for calculating the eco benefits of trees. All data used to calculate benefits is ripped from OpenStreetMaps otm-ecoservice
repository which was (probably) ripped from i-Tree's Eco or Streets software. A single tree is represented by 15 rows and 8 columns as there are 15 benefits calculated for every tree. Since tree inventories can be rather large, treeco
utilizes the data.table
package for speed. All calculations are done on unique species/dbh pairs to avoid redundant computation.
treeco
isn't available on CRAN but you can install it directly from github using devtools
:
# install.packages("devtools") devtools::install_github("tylurp/treeco")
We can use the trees
dataset to demonstrate how eco_guess
and eco_run_all
works:
library(dplyr) library(treeco) df_trees <- trees %>% mutate(common_name = "Black cherry") %>% select(common_name, Girth) %>% mutate(botanical_name = eco_guess(common_name, "botanical")) eco_run_all( data = df_trees, # dataset or path to CSV common_col = "common_name", # common name field botanical_col = "botanical_name", # botanical name field dbh_col = "Girth", # dbh field region = "PiedmtCLT", # region code n = 0.99, # optional, threshold for species guessing ) %>% as_tibble()
Use eco_run
to calculate benefits for a single tree:
treeco::eco_run("Common fig", 20, "InlEmpCLM")
One issue with eco benefits is that they all rely on i-Tree's master_species_list
which is a list of 3,000+ species, therefore a users data needs to fit this list in order to extract benefits. For example, "Commn fig" doesn't match i-Tree's "Common fig" because of the typo. So far, there really isn't a great solution to this. For now, treeco
guesses the species code on the fly by quantifying the "similarity", anything below 90% similar is immediately discarded.
For example, if we misspell "Common fig" as "Commn fig":
treeco::eco_run("Commn fig", 20, "InlEmpCLM")
If you are missing a field, you can use eco_guess
to try and find it:
x <- c("common fig", "red maple", "fir") treeco::eco_guess(x, "botanical")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.