This function imports a dataset downloaded from GBIF using a request key
generated by the request_gbif() function. It optionally allows saving
the imported occurrences to disk in CSV or GZIP format.
Usage
import_gbif(
request_key,
write_file = FALSE,
output_dir = NULL,
file.format = "gz",
select_columns = TRUE,
columns_to_import = NULL,
overwrite = FALSE,
...
)Arguments
- request_key
an object of class 'request_key' returned by the
request_gbif()function.- write_file
whether to save the downloaded occurrences to disk. Default is FALSE. If TRUE, you must specify the
output_dir.- output_dir
(character) a directory to save the data downloaded from GBIF. Only applicable if
write_file = TRUE. Default is NULL.- file.format
(character) the format to save the file. Options available are 'csv' (comma-separated values) and 'gz' (compressed GZIP). Only applicable if
write_file = TRUE. Default is 'gz'.- select_columns
(logical) whether to import only specific columns (TRUE) or all columns (FALSE) from the occurrence table. Default is TRUE.
- columns_to_import
(character) vector of column names to import. Default is NULL, meaning it will import the column names specified in
RuHere::gbif_columnsdata.- overwrite
(logical) whether to overwrite the file in the 'output_dir' if it already exists. Default is FALSE.
- ...
other arguments passed to
rgbif::occ_download_import().
Value
A data frame containing the GBIF occurrence records. If write_file = TRUE,
the function also saves the dataset to disk in the specified format.
Examples
if (FALSE) { # \dontrun{
# Prepare data to request GBIF download
gbif_prepared <- prepare_gbif_download(species = "Araucaria angustifolia")
# Submit a request to download occurrences
gbif_requested <- request_gbif(gbif_info = gbif_prepared)
# Check progress
rgbif::occ_download_wait(gbif_requested)
# After succeeded, import data
occ_gbif <- import_gbif(request_key = gbif_requested)
} # }
