README
gcube
The goal of gcube is to provide a simulation framework for biodiversity data cubes using the R programming language. This can start from simulating multiple species distributed in a landscape over a temporal scope. In a second phase, the simulation of a variety of observation processes and effort can generate actual occurrence datasets. Based on their (simulated) spatial uncertainty, occurrences can then be designated to a grid to form a data cube.
Simulation studies offer numerous benefits due to their ability to mimic real-world scenarios in controlled and customizable environments. Ecosystems and biodiversity data are very complex and involve a multitude of interacting factors. Simulations allow researchers to model and understand the complexity of ecological systems by varying parameters such as spatial and/or temporal clustering, species prevalence, etc.
Installation
You can install the development version from GitHub with:
Package name rationale and origin story
The name gcube stands for “generate cube” since it can be used to generate biodiversity data cubes from minimal input. It was first developed during the hackathon “Hacking Biodiversity Data Cubes for Policy”, where it won the first price in the category “Visualization and training”. You can read the full story here: https://doi.org/10.37044/osf.io/vcyr7
Example
This is a basic example which shows the workflow for simulating a biodiversity data cube. It is divided in three steps or processes:
- Occurrence process
- Detection process
- Grid designation process
The functions are set up such that a single polygon as input is enough to go through this workflow using default arguments. The user can change these arguments to allow for more flexibility.
We create a polygon as input. It represents the spatial extend of the species.
Occurrence process
We generate occurrence points within the polygon using the simulate_occurrences()
function.
In this function, the user can specify different levels of spatial clustering, and define the trend of number of occurrences over time.
The default is a random spatial pattern and a single time point with rpois(1, 50)
occurrences.
Detection process
In the second step we define the sampling process, based on the detection probability of the species and the sampling bias.
This is done using the sample_observations()
function.
The default sampling bias is "no_bias"
, but bias can be added using a polygon or a grid as well.
We select the detected occurrences and add an uncertainty to these observations.
This can be done using the filter_observations()
and add_coordinate_uncertainty()
functions, respectively.
Grid designation process
Finally, observations are designated to a grid with grid_designation()
to create an occurrence cube.
We create a grid over the spatial extend using sf::st_make_grid()
.
To create an occurrence cube, grid_designation()
will randomly take a point within the uncertainty circle around the observations.
These points can be extracted by setting the argument aggregate = FALSE
.
The output gives the number of observations per grid cell and minimal coordinate uncertainty per grid cell.
Cubes for multiple species
Each cube simulation function mentioned earlier has a corresponding mapping function.
These mapping functions are designed to handle operations for multiple species simultaneously by using the purrr::pmap()
function.
Please consult the documentation for detailed information on how these mapping functions are implemented.
single species | multiple species |
---|---|
simulate_occurrences() | map_simulate_occurrences() |
sample_observations() | map_sample_observations() |
filter_observations() | map_filter_observations() |
add_coordinate_uncertainty() | map_add_coordinate_uncertainty() |
grid_designation() | map_grid_designation() |