项目作者: tyluRp

项目描述 :
:deciduous_tree: Ecosystem benefits of Trees
高级语言: R
项目地址: git://github.com/tyluRp/treeco.git
创建时间: 2018-08-10T20:05:47Z
项目社区:https://github.com/tyluRp/treeco

开源协议:MIT License

下载


" class="reference-link">treeco

Travis build
status
AppVeyor build
status
Coverage
status
lifecycle

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.

Installation

treeco isn’t available on CRAN but you can install it directly from
github using devtools:

  1. # install.packages("devtools")
  2. devtools::install_github("tylurp/treeco")

A reproducible example

We can use the
trees
dataset to demonstrate how eco_guess and eco_run_all works:

  1. library(dplyr)
  2. library(treeco)
  3. df_trees <- trees %>%
  4. mutate(common_name = "Black cherry") %>%
  5. select(common_name, Girth) %>%
  6. mutate(botanical_name = eco_guess(common_name, "botanical"))
  7. eco_run_all(
  8. data = df_trees, # dataset or path to CSV
  9. common_col = "common_name", # common name field
  10. botanical_col = "botanical_name", # botanical name field
  11. dbh_col = "Girth", # dbh field
  12. region = "PiedmtCLT", # region code
  13. n = 0.99, # optional, threshold for species guessing
  14. ) %>% as_tibble()
  15. #> # A tibble: 465 x 8
  16. #> botanical common dbh benefit_value benefit unit dollars rn
  17. #> <chr> <chr> <dbl> <dbl> <chr> <chr> <dbl> <chr>
  18. #> 1 prunus sero… black c… 8.3 0.0776 aq nox a… lb 0.51 1
  19. #> 2 prunus sero… black c… 8.3 0.026 aq nox d… lb 0.17 1
  20. #> 3 prunus sero… black c… 8.3 0.0556 aq ozone… lb 0.36 1
  21. #> 4 prunus sero… black c… 8.3 0.015 aq pm10 … lb 0.04 1
  22. #> 5 prunus sero… black c… 8.3 0.0633 aq pm10 … lb 0.16 1
  23. #> 6 prunus sero… black c… 8.3 0.165 aq sox a… lb 0.32 1
  24. #> 7 prunus sero… black c… 8.3 0.0119 aq sox d… lb 0.02 1
  25. #> 8 prunus sero… black c… 8.3 0.0146 aq voc a… lb 0.09 1
  26. #> 9 prunus sero… black c… 8.3 -0.338 bvoc lb 2.12 1
  27. #> 10 prunus sero… black c… 8.3 30.3 co2 avoi… lb 0.23 1
  28. #> # ... with 455 more rows

More examples

Use eco_run to calculate benefits for a single tree:

  1. treeco::eco_run("Common fig", 20, "InlEmpCLM")
  2. #> common_name dbh benefit_value benefit unit dollars
  3. #> 1: Common fig 20 0.2429 aq nox avoided lb 0.93
  4. #> 2: Common fig 20 0.2623 aq nox dep lb 1.01
  5. #> 3: Common fig 20 0.7716 aq ozone dep lb 2.96
  6. #> 4: Common fig 20 0.0602 aq pm10 avoided lb 0.28
  7. #> 5: Common fig 20 0.4079 aq pm10 dep lb 1.89
  8. #> 6: Common fig 20 0.4813 aq sox avoided lb 1.17
  9. #> 7: Common fig 20 0.0353 aq sox dep lb 0.09
  10. #> 8: Common fig 20 0.0602 aq voc avoided lb 0.12
  11. #> 9: Common fig 20 0.0000 bvoc lb 0.00
  12. #> 10: Common fig 20 122.7973 co2 avoided lb 0.41
  13. #> 11: Common fig 20 9.0389 co2 sequestered lb 0.03
  14. #> 12: Common fig 20 1255.7516 co2 storage lb 4.19
  15. #> 13: Common fig 20 189.2000 electricity kwh 38.12
  16. #> 14: Common fig 20 834.7837 hydro interception gal 4.59
  17. #> 15: Common fig 20 -179.4561 natural gas lb 1.20

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”:

  1. treeco::eco_run("Commn fig", 20, "InlEmpCLM")
  2. #> Species given: [commn fig]
  3. #> Closest match: [common fig]
  4. #> ...
  5. #> Using closest match
  6. #> common_name dbh benefit_value benefit unit dollars
  7. #> 1: Common fig 20 0.2429 aq nox avoided lb 0.93
  8. #> 2: Common fig 20 0.2623 aq nox dep lb 1.01
  9. #> 3: Common fig 20 0.7716 aq ozone dep lb 2.96
  10. #> 4: Common fig 20 0.0602 aq pm10 avoided lb 0.28
  11. #> 5: Common fig 20 0.4079 aq pm10 dep lb 1.89
  12. #> 6: Common fig 20 0.4813 aq sox avoided lb 1.17
  13. #> 7: Common fig 20 0.0353 aq sox dep lb 0.09
  14. #> 8: Common fig 20 0.0602 aq voc avoided lb 0.12
  15. #> 9: Common fig 20 0.0000 bvoc lb 0.00
  16. #> 10: Common fig 20 122.7973 co2 avoided lb 0.41
  17. #> 11: Common fig 20 9.0389 co2 sequestered lb 0.03
  18. #> 12: Common fig 20 1255.7516 co2 storage lb 4.19
  19. #> 13: Common fig 20 189.2000 electricity kwh 38.12
  20. #> 14: Common fig 20 834.7837 hydro interception gal 4.59
  21. #> 15: Common fig 20 -179.4561 natural gas lb 1.20

If you are missing a field, you can use eco_guess to try and find it:

  1. x <- c("common fig", "red maple", "fir")
  2. treeco::eco_guess(x, "botanical")
  3. #> [1] "ficus carica" "acer rubrum" "abies spp"