library(ebvcube)
# Tutorial reference dataset. The download is cached in the temporary folder
# during the render, so it is not requested again when already present.
nc <- ebv_download(id = 30, outputdir = tempdir(), overwrite = FALSE)
#> [1] "Downloading file... Please wait."
# To validate your own file instead, use for example:
# nc <- "path/to/your_ebvcube.nc"
cubes <- ebv_datacubepaths(nc, verbose = FALSE)
props <- ebv_properties(nc, verbose = FALSE)
dc <- cubes$datacubepaths[1]
entity <- 1
timestep <- length(props@temporal$dates)5 Validating and visualising your EBVCube
By the end you will be able to:
- inspect the structure and metadata of a finished EBVCube;
- check whether a selected data slice contains plausible values;
- create a map and a temporal trend to inspect the data visually; and
- complete a short pre-upload checklist.
In Chapter 4 you created an EBVCube and checked that data could be written to it. This unit is the final check before upload. It does not prove that the underlying science is correct; it confirms that the file contains the data and metadata you intended to publish.
Use the metadata JSON, source rasters, and creation settings from Units 3 and 4 as your reference. The file alone cannot tell you what its intended extent, units, or values should have been.
Validation has four parts:
STRUCTURE
Are the expected cubes present?
ebv_datacubepaths() lists the data cubes; ebv_properties() reads the file metadata.
VALUES
Do the numbers make sense?
ebv_analyse() reports the range, summary statistics, and number of valid pixels.
VISUAL
Does the pattern look right?
ebv_map() and ebv_trend() make a map and a time-series plot directly from the cube.
METADATA
Does the file describe the data accurately?
Compare the stored title, dates, entity names, and metric information with your metadata JSON.
5.1 Choose the file and slice to inspect
The rendered examples use the tutorial reference dataset (portal ID 30), so that the map and trend are visible in this unit. When validating your own file, replace nc with the path to the EBVCube you created in Chapter 4. The example selects the first available data cube, its first entity, and its final time step. These are choices for inspection, not assumptions about your data: replace them with the cube, entity, and date you want to check.
5.2 1. Check the structure
ebv_datacubepaths() lists the data cubes stored in the file. A data-cube path represents a scenario and metric combination when scenarios are present. Entities are stored as a dimension within each cube, so check their names separately.
cubes
#> datacubepaths scenario_names
#> 1 scenario_1/metric_1/ebv_cube SSP1xRCP2.6 LU
#> 2 scenario_1/metric_2/ebv_cube SSP1xRCP2.6 LU
#> 3 scenario_1/metric_3/ebv_cube SSP1xRCP2.6 LU
#> 4 scenario_2/metric_1/ebv_cube SSP3xRCP6.0 LU
#> 5 scenario_2/metric_2/ebv_cube SSP3xRCP6.0 LU
#> 6 scenario_2/metric_3/ebv_cube SSP3xRCP6.0 LU
#> 7 scenario_3/metric_1/ebv_cube SSP5xRCP8.5 LU
#> 8 scenario_3/metric_2/ebv_cube SSP5xRCP8.5 LU
#> 9 scenario_3/metric_3/ebv_cube SSP5xRCP8.5 LU
#> metric_names
#> 1 Species richness (S)
#> 2 Relative species richness change (Delta_S)
#> 3 Diversity-weighted relative species richness change (Delta_SS)
#> 4 Species richness (S)
#> 5 Relative species richness change (Delta_S)
#> 6 Diversity-weighted relative species richness change (Delta_SS)
#> 7 Species richness (S)
#> 8 Relative species richness change (Delta_S)
#> 9 Diversity-weighted relative species richness change (Delta_SS)
props@general$entity_names
#> [1] "All birds" "Forest birds" "Non-forest birds"
props@spatial$extent
#> [1] -180 180 -90 90
props@temporal$dates
#> [1] "1900-01-01" "2015-01-01" "2050-01-01"Compare this output with the metadata and source data you prepared. The number of paths should equal the number of scenario–metric combinations you intended to create. For the tutorial reference dataset, that is three scenarios times three metrics, or nine paths. A file without scenarios can correctly have only one path per metric.
Check that the entity names, spatial extent, and dates match what you declared. A missing cube, an unexpected entity name, or an empty time axis is a reason to return to the creation workflow before uploading.
5.3 2. Check the values
The file structure can be correct even when a cube contains no usable values. ebv_analyse() summarises the selected slice without requiring you to read the complete cube into memory:
stats <- ebv_analyse(
nc, dc, entity = entity, timestep = timestep, verbose = FALSE
)
stats[c("min", "mean", "max", "n", "NAs")]
#> $min
#> [1] 2.999974
#>
#> $mean
#> [1] 197.5901
#>
#> $max
#> [1] 1004.216
#>
#> $n
#> [1] 64800
#>
#> $NAs
#> [1] 48077n is the number of valid pixels. Compare the minimum, maximum, and mean with the units and expected range of your source data. If n is zero, or all cells are NA, that slice was not populated. A value outside the expected range can indicate a unit mismatch, an unexpected fill value, or an issue in the source raster.
If the data covers a large area, repeat this check for a smaller region that you know well. Use a bounding box or shapefile subset only when you can confirm that it overlaps the cube and uses the same coordinate reference system.
5.4 3. Inspect the data visually
Visual checks make spatial and temporal problems easier to spot. They complement the numerical summary above: a plausible mean can still hide data in the wrong place or a sudden change at one date.
ebv_map() creates a map for one entity and time step. Confirm that the data appears in the expected geographic area and that missing areas are plausible for the dataset.
ebv_trend() plots one summary value for each time step and returns those values. Look for a flat line when change is expected, an unexplained jump, or a missing time step. Whether a particular pattern is plausible must be judged against your data and method.
If you want a presentation-ready figure, reuse the values returned by ebv_trend() with ggplot2. This is optional and does not add another validation requirement. Install ggplot2 first if it is not already available.
# install.packages("ggplot2") # run once, only if needed
trend_data <- data.frame(
date = props@temporal$dates,
value = trend_values
)
ggplot2::ggplot(trend_data, ggplot2::aes(date, value)) +
ggplot2::geom_line(linewidth = 0.9, colour = "#167A5A") +
ggplot2::geom_point(size = 2, colour = "#167A5A") +
ggplot2::labs(
title = "Mean value over time",
x = NULL,
y = "Mean value"
) +
ggplot2::theme_minimal(base_size = 12)This can happen when a raster uses the [0, 360] longitude convention and you add a [-180, 180] basemap. When creating your own map from ebv_read(), rotate the raster before plotting. This changes the display raster, not the EBVCube file.
r <- ebv_read(nc, dc, entity = entity, timestep = timestep, type = "r")
r <- terra::rotate(r)5.5 4. Compare against your metadata
Read the stored information back from the file and compare it with the metadata JSON or the values supplied through ebv_metadata(). Use the selected data-cube path to include metric-specific information.
cube_props <- ebv_properties(nc, dc, verbose = FALSE)
props@general$title
#> [1] "Global trends in biodiversity (BES-SIM cSAR-iDiv)"
props@general$entity_names
#> [1] "All birds" "Forest birds" "Non-forest birds"
props@temporal$dates
#> [1] "1900-01-01" "2015-01-01" "2050-01-01"
cube_props@metric
#> $name
#> [1] "Species richness (S)"
#>
#> $description
#> [1] "Species richness per cell"
#>
#> $units
#> [1] "Number of species"The title, entity names, temporal coverage, metric name, description, and units should agree with the metadata you intend to submit. If you find an incorrect attribute, correct it with ebv_attribute() as described in Chapter 4, then repeat the affected checks.
5.6 Pre-upload checklist
Before continuing to the portal, confirm the following:
Checkpoint. You have checked the structure, values, visual pattern, and metadata of your EBVCube against the information you prepared. You are now ready to upload the file in Chapter 6.

