Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

occ_download_import

Import a downloaded file from GBIF.


Description

Import a downloaded file from GBIF.

Usage

occ_download_import(
  x = NULL,
  key = NULL,
  path = ".",
  fill = FALSE,
  encoding = "UTF-8",
  ...
)

as.download(path = ".", key = NULL)

## S3 method for class 'character'
as.download(path = ".", key = NULL)

## S3 method for class 'download'
as.download(path = ".", key = NULL)

Arguments

x

The output of a call to occ_download_get

key

A key generated from a request, like that from occ_download

path

Path to unzip file to. Default: "." Writes to folder matching zip file name

fill

(logical) (default: FALSE). If TRUE then in case the rows have unequal length, blank fields are implicitly filled. passed on to fill parameter in data.table::fread.

encoding

(character) encoding to read in data; passed to data.table::fread(). default: "UTF-8". other allowed options: "Latin-1" and "unknown". see ?data.table::fread docs

...

parameters passed on to data.table::fread()

Details

You can provide either x as input, or both key and path. We use data.table::fread() internally to read data.

Value

a tibble (data.frame)

Problems reading data

You may run into errors when using occ_download_import(); most often these are due to data.table::fread() not being able to parse the occurrence.txt file correctly. The fill parameter passes down to data.table::fread() and the ... allows you to pass on any other parameters that data.table::fread() accepts. Read the docs for fread for help.

Note

see downloads for an overview of GBIF downloads methods

See Also

Examples

## Not run: 
# First, kick off at least 1 download, then wait for the job to be complete
# Then use your download keys
res <- occ_download_get(key="0000066-140928181241064", overwrite=TRUE)
occ_download_import(res)

occ_download_get(key="0000066-140928181241064", overwrite = TRUE) %>%
  occ_download_import

# coerce a file path to the right class to feed to occ_download_import
# as.download("0000066-140928181241064.zip")
# as.download(key = "0000066-140928181241064")
# occ_download_import(as.download("0000066-140928181241064.zip"))

# download a dump that has a CSV file
# res <- occ_download_get(key = "0001369-160509122628363", overwrite=TRUE)
# occ_download_import(res)
# occ_download_import(key = "0001369-160509122628363")

# download and import a species list (in csv format)
# x <- occ_download_get("0000172-190415153152247")
# occ_download_import(x)

## End(Not run)

rgbif

Interface to the Global 'Biodiversity' Information Facility API

v3.5.2
MIT + file LICENSE
Authors
Scott Chamberlain [aut, cre] (<https://orcid.org/0000-0003-1444-9135>), Damiano Oldoni [aut] (<https://orcid.org/0000-0003-3445-7562>), Vijay Barve [ctb] (<https://orcid.org/0000-0002-4852-2567>), Peter Desmet [ctb] (<https://orcid.org/0000-0002-8442-8025>), Laurens Geffert [ctb], Dan Mcglinn [ctb] (<https://orcid.org/0000-0003-2359-3526>), Karthik Ram [ctb] (<https://orcid.org/0000-0002-0233-1757>), rOpenSci [fnd] (https://ropensci.org/)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.