3  Preparing biodiversity data and metadata

In this unit

By the end you will be able to:

  • identify the data and metadata needed to create an EBVCube;
  • interpret the scenario–metric structure of a EBVCube;
  • distinguish data cubes from the spatial layers used to populate them;
  • create a metadata JSON through the EBV Data Portal or R;
  • prepare your own biodiversity data for EBVCube creation.

Until now, you have explored a published EBVCube. In this unit, you will look more closely at how that file is organised and identify the information and data needed to create one yourself.

Creating an EBVCube involves four main steps: (1) prepare the metadata, (2) create an empty netCDF with the intended structure, (3) populate its data cubes, and (4) adjust attributes where needed. This unit focuses on preparing the data and metadata required for the first step. In Unit 4, you will use them to create and populate the file.

How to use this unit

Follow the example - This is the main route through the unit. You do not need your own raster data: dataset id = 30 provides a real, published EBVCube that you can use to understand the required structure and metadata.

Apply it to your own data - If you already have model outputs or other biodiversity data, you can use the preparation checklist in this unit to get them ready for EBVCube creation.

3.1 Inspect the structure of a published EBVCube

Start by inspecting the structure of dataset id = 30, the published EBVCube used throughout this tutorial. The dataset contains three scenarios and three metrics. Since each scenario–metric combination is stored as a separate data cube, we expect the file to contain nine data cubes.

# Load library 
library(ebvcube)
# Download dataset with id=30
file <- ebv_download(id = 30, outputdir = tempdir(), overwrite = FALSE)
# Get data cubes paths
paths <- ebv_datacubepaths(file, verbose = FALSE)
nrow(paths)
#> [1] 9
paths

The result confirms that the file contains nine data cubes. Each scenario–metric combination has its own path, for example scenario_1/metric_1/ebv_cube.

Why inspect the structure first?

Functions such as ebv_datacubepaths() let you understand how a published EBVCube is organised before reading its values. This is useful when deciding which scenario, metric, time step, or entity you want to access.

3.2 What you need before creating an EBVCube

Before creating an EBVCube, you need to define its structure and prepare the data that will populate it. ebv_create() uses the information you provide; it does not infer the intended structure from the input rasters. Four components therefore need to be prepared:

A metadata JSON

Describes the dataset and its hierarchy, including the title, creators, licence, EBV class, metrics, and scenarios. You can create it through the EBV Data Portal or, optionally, with ebv_metadata().

Data values

The spatial values that will populate the data cubes. These can come from individual raster layers or from multiple time steps stored in multi-band GeoTIFFs.

Entity names

The biological units represented in the data, provided in a fixed order. In dataset id = 30, these are All birds, Forest birds, and Non-forest birds.

Creation settings

The coordinate reference system, spatial extent, resolution, exact time steps, and no-data value used to define the dimensions of the EBVCube. You provide these to ebv_create() in Unit 4.

Coverage and exact time steps are different

The metadata JSON describes the dataset’s temporal coverage, for example 1900–2050. The exact time steps stored in the EBVCube, such as 1900, 2015, and 2050, are provided separately through ebv_create(timesteps = ...) in Unit 4.

The same principle applies to space: the metadata describes the dataset’s spatial coverage, while ebv_create() receives the exact coordinate reference system, extent, and resolution used to construct the grid.

3.3 Data cubes and spatial layers are not the same

Dataset id = 30 illustrates an important distinction between the number of data cubes in an EBVCube and the number of two-dimensional spatial layers needed to populate them.

In dataset id = 30 Calculation Result
Data cubes 3 scenarios × 3 metrics 9
Two-dimensional map layers 3 entities × 3 dates × 3 scenarios × 3 metrics 81

Each of the nine data cubes has four dimensions: longitude, latitude, time, and entity. With three entities and three dates, each cube contains nine two-dimensional spatial slices. Across nine cubes, this gives 81 spatial slices.

These slices do not necessarily correspond to 81 separate files. For example, several time steps can be stored together in a multi-band GeoTIFF.

The key distinction is therefore:

  • scenarios × metrics determines the number of data cubes;
  • entities × dates × scenarios × metrics determines the number of spatial slices needed to populate them.

## Prepare your own data

If you are following the published example, use this section as a checklist for later. If you are working with your own biodiversity data, check these points before continuing to Unit 4.

One shared grid

Every layer has the same coordinate reference system, extent, and resolution.

Complete data coverage

You can account for every combination of entity, time step, metric, and scenario that the EBVCube will contain.

Final entity names

One name per entity, in the same order in your metadata and data layers.

Exact creation settings

You know the EPSG code, extent, resolution, time steps, and fill value you will pass to ebv_create().

Consistent source data

Your GeoTIFFs or in-memory rasters load correctly, use the expected grid, and represent missing values consistently.

# Install and/or load library
install.package('terra')
library(terra)

# List all the GeoTIFFs from your folder
layers <- rast(list.files("path/to/your/tifs", pattern = "\\.tif$",
                          full.names = TRUE))
layers  # inspect extent, resolution, CRS, and number of layers

Use this only with your own data. It is a quick first check, not a replacement for checking that each layer has the intended entity, date, metric, and scenario.

3.4 Create the metadata JSON

Every EBVCube is created from a metadata JSON that describes the dataset and its scenario–metric hierarchy. There are two ways to create it. The EBV Data Portal - is the recommended route since its form guides you through the required fields and controlled vocabularies. Alternatively, ebv_metadata() allows you to generate the metadata in R.

3.4.1 Path A — EBV Data Portal

Open Uploads → New Upload in the EBV Data Portal. Complete the required fields in the first two tabs, then use the third tab to generate and download the metadata JSON.

Add the title, creation date, summary, methods, creators, licence, and related DOIs, among other general information.

EBV Data Portal new upload, General information tab
Figure 3.1: New upload — General information.

Choose the EBV class, EBV name, and entity type from the portal’s fixed lists. Add the metrics, including their names, descriptions, and units. Add scenarios when the same metrics occur under alternative projected pathways.

EBV Data Portal new upload, EBV attributes tab
Figure 3.2: New upload — EBV attributes.

Click Download Metadata to save the .json file. This is the file you pass to ebv_create() in Unit 4. You return to this tab later to upload the finished netCDF.

EBV Data Portal new upload, Data upload tab
Figure 3.3: New upload — Data upload, with the Download Metadata link.
A GEO BON account is required

You need a GEO BON account at members.geobon.org to access the upload workflow, create and download the metadata JSON, and later submit the completed EBVCube through the EBV Data Portal.

3.4.2 Path B — R with ebv_metadata()

Use ebv_metadata() when you want to generate metadata programmatically. The example below uses dataset id = 30 to illustrate how the same type of metadata can be defined in R. It is intended as a learning example; replace all dataset-specific information when creating an EBVCube from your own data.

json <- ebv_metadata(
  outputpath            = file.path(tempdir(), "metadata.json"),
  title                 = "Global trends in biodiversity (BES-SIM cSAR-iDiv)",
  summary               = "Projections from the cSAR-iDiv model from 1900 to 2050 using LUH2 and SSP-RCP pathways for the BES-SIM inter-model comparison.",
  references            = "10.1126/science.adn3441",
  source                = "cSAR-iDiv model team, 14 December 2018",
  project_name          = "BES-SIM",
  project_url           = "https://ipbes.net/scenarios-models/expert-group-activities",
  date_created          = "2022-03-21",
  creator_name          = "Inês Martins",
  creator_institution   = "German Centre for Integrative Biodiversity Research (iDiv)",
  contributor_name      = "Henrique M. Pereira",
  license               = "CC BY",
  ebv_class             = "Community composition",
  ebv_name              = "Taxonomic and phylogenetic diversity",
  ebv_spatial_scope     = "Global",
  ebv_domain            = "Terrestrial",
  coverage_content_type = "modelResult",
  ebv_entity_type       = "Communities",
  ebv_entity_scope      = "Bird species (forest and non-forest)",
  time_coverage_start      = "1900-01-01",
  time_coverage_end        = "2050-01-01",
  time_coverage_resolution = "Irregular",
  ebv_scenario_classification_name    = "SSP-RCP",
  ebv_scenario_classification_version = "LUH2, CMIP5/ISIMIP2a",
  metric = list(
    list(standard_name = "Species richness (S)",
         long_name     = "Species richness per cell",
         units         = "Number of species"),
    list(standard_name = "Relative species richness change (Delta_S)",
         long_name     = "Species richness change relative to the previous time step",
         units         = "%"),
    list(standard_name = "Diversity-weighted relative species richness change (Delta_SS)",
         long_name     = "Diversity-weighted relative species richness change",
         units         = "%")
  ),
  scenario = list(
    list(standard_name = "SSP1xRCP2.6 LU",
         long_name     = "Global Sustainability; land-use effects only"),
    list(standard_name = "SSP3xRCP6.0 LU",
         long_name     = "Regional Rivalry; land-use effects only"),
    list(standard_name = "SSP5xRCP8.5 LU",
         long_name     = "Fossil-Fuel Development; land-use effects only")
  ),
  overwrite = TRUE,
  verbose   = FALSE
)

Whichever path you choose, review the final JSON before building the file. Use the portal form or ?ebv_metadata to check controlled vocabulary values; do not invent close-sounding alternatives.

3.5 Before moving to Unit 4

You now have the information needed to define an EBVCube:

  • if you are following the tutorial example, you have inspected dataset id = 30 and identified its nine scenario–metric data cubes;
  • if you are working with your own data, you have checked the spatial layers, entity names, time steps, and creation settings;
  • in either case, you know how the metadata JSON defines the metrics and scenarios that determine the structure of the file.

Checkpoint. Before continuing, make sure you can explain the difference between the nine data cubes and the 81 spatial slices in dataset id = 30, and identify the metadata JSON, entity names, creation settings, and data values needed to create an EBVCube.

In Unit 4, you will use these components to create the netCDF and populate its data cubes.