The R Package for the SDCA Project
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")
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)