Skip to content

Files

Latest commit

ff31d3e · Jun 28, 2022

History

History
53 lines (34 loc) · 1.31 KB

README.md

File metadata and controls

53 lines (34 loc) · 1.31 KB

R-CMD-check

SDCA

The R Package for the SDCA Project

Installation

Ensure you have system dependencies:

sudo apt-get install -y libssl-dev libcurl4-openssl-dev libxml2-dev libudunits2-dev libgdal-dev

and R dependences:

R -e 'if (!require("units")) install.packages("units");'
R -e 'if (!require("sf")) install.packages("sf");'

Install the package with remotes as follows:

install.packages("remotes")
remotes::install_github("SDCA-tool/sdca-package")

Use

The primary use case of the package is working within the SDCA website. However users can test the code locally by drawing an intervention on the website, downloading the GeoJSON then.

library(sdca)
download_rasters() #first time only

# Path to the GeoJSON downloaded from website
path <- "carbon-calculator-scheme-intervention.geojson"

# Get data from the server
dat <- geojson_api(path)

# Process the input data using local = TRUE
results <- process_results(dat, local = TRUE)

# Convert results into R format
results <- jsonlite::fromJSON(results)