The Greenhouse Gas Value Calculator (GHGVC) uses the ghgvcR package to calculate greenhouse gas emissions. GHGVC can be installed at https://github.com/ebimodeling/ghgvc.

Citation: Kristina J. Teixeira and Evan H. Delucia 2011. The greenhouse gas value of ecosystems. Global Change Biology. 17(1):425438 doi: 10.1111/j.1365-2486.2010.02220.x

Overview

ghgvcR has several principal functions:

  1. get_biome() determines the biomes available at a given latitude and longitude.
  2. get_ncdf() reads in netcdf biome data for a given latitude and longitude.
  3. calc_ghgv() calculates the greenhouse gas emissions of a specific ecosystem.
  4. plot_ghgv() creates plots of greenhouse gas emissions seen on the GHGVC app.

ghgvcR talks to the GHGVC web app by receiving json parameters and passing back json results. However it also works as a stand alone estimator of greenhouse gas emissions at a specific location.

Quick Example

Several example ecosystem data files are kept in inst/config_examples/. These can be used in place of biome data to run the calculator entirely within R:

library(ghgvcr)

#load example config data
config_file <- system.file("config/single_site.json", package = "ghgvcr")

#Calculate
res <- calc_ghgv(system.file("config/single_site.json", package = "ghgvcr"))

#Write the data to a file:
#outdir <- "./"
#write_json(res, outdir, filename = "ghgvc_example", format="json")

ghgvcR can also plot the greenhouse gas values that are returned by calc_ghgv():

``` {r, fig.show='hold'}

df <- as.data.frame(res$site_1_data)

p <- ghgvc_plot(df, save = FALSE)

p

####Biome Example
The same calculation can be done for a specific location if biome data is available.

```r
#NOT RUN
library(ghgvcr)
data(biome_defaults)

#Example location
latitude <- 40.18
longitude <- -89.82

#paths
netcdf_dir <- "<data directory>"

#Load the biome data for that location
#biome <- get_biome(latitude, longitude, netcdf_dir, biome_defaults, write_data = FALSE)
#head(biome)

#Calculate GHGV
#res <- calc_ghgv(biome)

Working with GHGVC

ghgvcR works in concert with ghgvc through the ghgvcR scripts. This requires a certain amount of configuration. Once ghgvc is set up correctly, the following settings must be configured in app/workflows_controller.rb:

Where to find the ghgvcR scripts ghgvcR_scripts_path needs to be set. In development this is currently "/inst/scripts". In production, it may be better to place the scripts directory within the ghgvc app itself (e.g. "/ghgvcR/").

Where the netcdf data is stored By default the netcdf data is stored at "/netcdf/".

Where the name-indexed ecosystem json file is stored By default this is "/public/data/final_ecosystems.json".



ebimodeling/ghgvcR documentation built on April 28, 2021, 8:19 p.m.