Skip to contents

This function handles the downloading and processing of occurrence data from the Global Biodiversity Information Facility (GBIF). The function allows request data, download it, and optionally split it into smaller chunks for further analysis.

Usage

GBIF_Download(
  FromHPC = TRUE,
  EnvFile = ".env",
  Renviron = ".Renviron",
  RequestData = TRUE,
  DownloadData = TRUE,
  SplitChunks = TRUE,
  ChunkSize = 50000,
  Boundaries = c(-30, 50, 25, 75),
  StartYear = 1981
)

Arguments

FromHPC

Logical indicating whether the work is being done from HPC, to adjust file paths accordingly. Default: TRUE.

EnvFile

Character. The path to the environment file containing variables required by the function. Default is ".env".

Renviron

Character. The path to the .Renviron file containing GBIF login credentials (email, user, password).

RequestData

Logical. If TRUE, requests data from GBIF. If FALSE, loads a previously requested data set from GBIF_Request.RData and StatusDetailed.RData files. Defaults to TRUE.

DownloadData

Logical. If TRUE, downloaded data is stored on disk. Defaults to TRUE.

SplitChunks

Logical. If TRUE, splits the downloaded data into smaller chunks for easier processing.

ChunkSize

Integer. The number of records per chunk when splitting the data. Default is 50,000.

Boundaries

Numeric vector of length 4. Specifies geographical boundaries for the requested GBIF data in the order: Left, Right, Bottom, Top. Defaults to c(-30, 50, 25, 75).

StartYear

Numeric. The starting year for the occurrence data. Only records from this year onward will be requested from GBIF. Default is 1981, which matches the year ranges of CHELSA current climate data.

Value

The function does not return any value. The function is called for its side effects, including saving GBIF data and metadata.

Details

The function begins by checking for necessary GBIF access credentials. If these are not found in the environment, it attempts to read them from the provided .Renviron file. The function then loads essential paths and input data, such as country codes and species lists, from specified locations.

If RequestData is TRUE, the function requests data from GBIF using the specified criteria (taxa, coordinates, time period, and boundaries). The request status is saved, and the function waits until the data is ready. The data can then be downloaded and saved locally. If DownloadData is TRUE, the downloaded data is processed, and metadata is extracted and saved.

If SplitChunks is TRUE, the data is split into smaller chunks for easier handling.

Note

This function is not intended to be used directly by the user or in the IAS-pDT, but only used inside the GBIF_Process function.

Author

Ahmed El-Gabbas