Skip to content

kuytje/NatureDataCube-R

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

107 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NatureDataCube-R

This package provides R-based interface to NatureDataCube, both programmatic (i.e. R functions and wrappers) and graphical (through an R-Shiny app).

The idea of the NatureDataCube is to offer an accessible way for researchers/ecologists to retrieve relevant data.

NatureDataCube is a platform based on AgroDataCube, holding and providing access to data used in the context of project LTER-LIFE.

Main R functions

Via the NatureDataCube STAC API (see examples_ndc.ipynb and examples_stac.ipynb)

  • ndc_get: Search (and optionally download) data through a custom STAC query
  • ndc_datasets: List all datasets (optionally constrained by query parameters) in NatureDataCube.
  • ndc_count: Obtain a number of items available in NatureDataCube datasets (optionally constrained by query parameters).
  • ndc_roi: Import and transform spatial region of interest.
  • ndc_trange: Convert one or more dates to the RCF3339 format.
  • assets_download_wcs: Workaround for downloading STAC Assets coming from WCS servers.

Via the AgroDataCube REST API (see examples_adc.ipynb)

  • adc_url: Compose URL text string for submitting data requests through the REST API.
  • adc_get: Submit requests via REST API.

Via the GroenMonitor WCS GeoServer (see examples_gm.ipynb)

  • gm_url: Compose URL text string for submitting data requests through the GroenMonitor WCS GeoServer.
  • gm_get: Submit requests to the GroenMonitor WCS GeoServer.

To be implemented

  • Add (advanced) STAC filtering (e.g. post-fetching filtering, CQL2);
  • Add a way to easily list available date ranges within items matched with search parameters;
  • Add function(s) to deal with weather (point) data;
  • Add functions for post-processing (e.g. cropping acquired gridded data to RoI);
  • Harmonize functionality across the different data sources, ando also towards using the returned data within Digital Twins platforms (e.g. NaaVRE);
  • Generally improve all functions.

Shiny app

Opening the Shiny app

To use the Shiny app and continue working with the retrieved data in R, the app must be launched in a specific way so that the output is stored in an R object.

Steps:

  • Load the NatureDataCubeR package (e.g. by executing library(NatureDataCubeR)).
  • Make sure that your working directory is set to the folder you want to work from (this can be changed with setwd("path/to/workingdirectory"); note that getwd() can be used to check the current working directory).
  • Launch the Shiny app from within R by typing and executing data_ndc <- ndc_gui().

Launching the app in this way ensures that the output generated through the Shiny interface is returned and stored in the R variable data_nc (note that this can be changed to a different object name). This allows you to continue working with the retrieved data in R after closing the app.

To retrieve data from the NatureDataCube, an API token is required. Make sure your token is available in your R session before requesting data.

Generate an API token

To generate your free personal API token to retrieve data you can go to API Access Registration.

Running with Docker or Podman

The Shiny app can also be run as a container, which handles all package dependencies automatically.

Setup:

Copy .env.example to .env and fill in your API token:

NDC_TOKEN=your_token_here
SHINY_APP_BASE_URL=/naturedatacube

Run:

# Docker
docker compose up --build

# Podman
podman compose up --build

The app will be available at http://localhost:3838/naturedatacube.

About

R functions to interface with (and work with data from) NatureDataCube

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 88.7%
  • R 11.2%
  • Dockerfile 0.1%