7  Troubleshooting and getting help

In this unit

By the end you will be able to:

  • identify common installation problems and apply the appropriate fix;
  • check the inputs that cause ebv_create() and ebv_add_data() to fail;
  • resolve common problems when reading, validating, or mapping an EBVCube;
  • respond to upload and review problems in the EBV Data Portal; and
  • prepare a useful request for help or bug report.

This unit is a reference for problems that can occur while following the earlier units. The sections follow the same order as the tutorial, so you can go directly to the stage where the problem occurred. Open the entry that best matches the message or result you see, apply the suggested check, and then repeat the affected step.

7.1 Installing the package

These problems can prevent library(ebvcube) from loading. Return to Chapter 2 for the full installation steps.

An error such as there is no package called 'rhdf5', DelayedArray, or HDF5Array means that a required Bioconductor dependency is unavailable. Install the dependencies, then restart R and try loading ebvcube again:

install.packages("BiocManager")
BiocManager::install(c("rhdf5", "DelayedArray", "HDF5Array"))

library(ebvcube)

If BiocManager is already installed, the first line can be skipped. It selects the Bioconductor release that is compatible with your R version.

First check the installed R version:

R.version.string

ebvcube requires R 4.2.0 or later. Update R if the installed version is older, then repeat the installation in Chapter 2. If updating R is not possible, use a package version documented as compatible with your R version; check the package release notes before selecting a version.

This can indicate that the system libraries required by rhdf5 or terra are missing. On Debian or Ubuntu, install the libraries from a terminal:

sudo apt-get install libhdf5-dev libgdal-dev libproj-dev libgeos-dev libudunits2-dev

Then reinstall the dependency named in the error message, rather than only reinstalling ebvcube. Package names and installation commands differ on other Linux distributions; use the equivalent packages supplied by that distribution.

An HDF5 library version mismatched error can occur when rhdf5 was built against a different HDF5 library from the one loaded by R. Close all R sessions, start a clean session, and reinstall rhdf5:

remove.packages("rhdf5")
BiocManager::install("rhdf5", force = TRUE)

Then restart R once more and retry the operation.

7.2 Preparing data and metadata

Problems at this stage usually concern controlled vocabulary values or inputs that do not describe the same dataset. The complete preparation workflow is in Chapter 3.

Fields such as ebv_class, ebv_name, and ebv_entity_type accept controlled vocabulary values. If ebv_metadata() or the portal form rejects a value, compare it with the available options in the portal form or the accepted values in ?ebv_metadata. Use the listed wording rather than a close alternative.

Before creating the file, confirm that the spatial layers have a common coordinate reference system, extent, and resolution; that their ordering matches the entity names and time steps; and that the metadata JSON describes the same metrics and scenarios. These checks prevent most dimension and indexing problems during cube creation.

7.3 Creating the cube

Errors here often indicate that the metadata, creation settings, and supplied data do not describe the same dimensions. See Chapter 4 for the complete workflow.

ebv_create() requires one entity name for each entity declared by the metadata JSON. Compare the vector you supplied with the metadata, then correct the vector or JSON so their entity counts agree. Keep the entity order consistent with the order of the data supplied later.

This error can occur when the raster does not match the target cube’s coordinate reference system, resolution, extent, or number of layers. Read one target slice to use as a grid template, then align the input raster before adding it:

target_r <- ebv_read(
  new_nc, "scenario_1/metric_1/ebv_cube",
  entity = 1, timestep = 1, type = "r", verbose = FALSE
)

r <- terra::rast("your_data.tif")
r_aligned <- terra::project(r, target_r)
terra::writeRaster(r_aligned, "your_data_aligned.tif", overwrite = TRUE)

Replace the data-cube path, entity, and time step with a valid target in your file. Before calling ebv_add_data(), also check that the raster layers correspond to the time steps you provide.

Correct the affected attribute with ebv_attribute(), as shown in Chapter 4, then repeat the relevant checks in Chapter 5. Rebuilding the netCDF is not required solely to correct an attribute.

7.4 Reading and validating the file

These issues can occur while checking your own file or reading a published EBVCube. The standard validation checks are in Chapter 5.

The selected cube or slice is larger than the available memory limit. Reduce the amount read by using ebv_read_bb() for a bounding box or ebv_read_shp() for a polygon, or use type = "da" to work with a DelayedArray on disk. ignore_RAM = TRUE disables the package’s safety check; it does not reduce the amount of memory a normal read requires.

First check whether the polygon overlaps the cube’s extent. If it does, compare its coordinate reference system with a raster read from the cube. Reproject the polygon to the target raster’s CRS before saving it and trying the subset again:

target_r <- ebv_read(nc, dc, entity = 1, timestep = 1, type = "r",
                     verbose = FALSE)
shp_aligned <- sf::st_transform(sf::st_read(shp), terra::crs(target_r))
sf::st_write(shp_aligned, "shp_aligned.shp", delete_dsn = TRUE)

terra::ext(target_r)
sf::st_bbox(shp_aligned)

The final two lines provide the two extents for comparison. Use the saved, aligned shapefile in ebv_read_shp() only when the extents overlap.

This can occur when the raster uses longitudes from [0, 360] and a basemap uses [-180, 180]. When creating a custom map from ebv_read(), rotate the display raster before plotting:

r <- ebv_read(nc, dc, entity = entity, timestep = timestep, type = "r")
r <- terra::rotate(r)

This changes the raster used for display, not the EBVCube file.

7.5 Uploading to the portal

The submission steps are in Chapter 6. Use the portal’s validation feedback to identify whether the file, metadata, or submission information needs attention.

Run the checklist in Chapter 5 again and correct any reported issue before uploading a revised file. Confirm that the file and portal fields refer to the same dataset and that the upload has finished before leaving the page. If the problem continues after a successful local validation, record the portal message, the time of the attempt, and the dataset draft or submission identifier, then contact the portal team through the dataset page or GEO BON contact route.

The portal lists the values it accepts for controlled fields. Select a term only when it accurately describes the dataset. If none of the available terms fits, ask the portal team for guidance rather than substituting an inaccurate value or editing the metadata to bypass the form.

Review requires action by the portal team and may result in a request for changes. Check the submission page and the email address associated with the account for feedback. If there has been no update after a reasonable review period, contact the portal team with the dataset identifier and submission date.

7.6 Working with large files

netCDF/HDF5 files can require many small reads. A network drive can add delay to each one. Where your data-handling policy permits it, copy the file to a local working directory before reading it:

local_nc <- file.path(tempdir(), basename(nc))
file.copy(nc, local_nc, overwrite = TRUE)

Use local_nc for the read, while retaining the original file unchanged.

For an exploratory map, read a selected slice and aggregate it before plotting. Choose a factor that retains the geographic pattern needed for the check:

r <- ebv_read(nc, dc, entity = entity, timestep = timestep, type = "r")
r_small <- terra::aggregate(r, fact = 4, fun = "mean")
plot(r_small)

Use the original-resolution data for the final analysis or export when required.

7.7 Keep a recoverable workflow

Before and after each correction

Keep a copy of the metadata JSON, the netCDF you validated before upload, and the script used to create the file. Record what you changed, then repeat the relevant validation checks in Chapter 5. When referring to a published dataset, cite its DOI from the portal page; use citation("ebvcube") when citing the software itself.

7.8 Getting help and reporting bugs

If the entries above do not resolve the problem, first identify whether it occurs in the package or in the portal. Report package errors through the GitHub issue tracker. For a question about using the package, use GitHub Discussions. For a portal upload, review, or metadata-form issue, use the portal contact route.

A report is easier to investigate when it includes:

  • the complete error message;
  • the output of sessionInfo() and packageVersion("ebvcube");
  • a minimal reproducible example, where possible; and
  • the result you expected and the result you observed.

Do not include data that you are not permitted to share. If the problem has already been fixed in a newer release, updating the package may resolve it; check the installed version before posting.

Checkpoint. You can identify the stage where a problem occurred, apply the relevant check or correction, and collect the information needed for further help. For additional documentation and references, see Chapter 8.