Last chance! 50% off unlimited learning
Sale ends in
Import a downloaded file from GBIF.
occ_download_import(
x = NULL,
key = NULL,
path = ".",
fill = FALSE,
encoding = "UTF-8",
...
)as.download(path = ".", key = NULL)
# S3 method for character
as.download(path = ".", key = NULL)
# S3 method for download
as.download(path = ".", key = NULL)
a tibble (data.frame)
The output of a call to occ_download_get
A key generated from a request, like that from
occ_download
Path to unzip file to. Default: "."
Writes to
folder matching zip file name
(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.
(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()
. See fread
docs for details. Some fread
parameters that may be particular useful
here are: select
(select which columns to read in; others are dropped),
nrows
(only read in a certain number of rows)
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.
The country code for Namibia is "NA"
. Unfortunately in R an "NA"
string
will be read in to R as an NA/missing. To avoid this, in this function
we read in the data, then convert an NA/missing values to the character
string "NA"
. When a country code is truly missing it will be an empty
string.
You can provide either x as input, or both key and path. We use
data.table::fread()
internally to read data.
Other downloads:
download_predicate_dsl
,
occ_download_cached()
,
occ_download_cancel()
,
occ_download_dataset_activity()
,
occ_download_datasets()
,
occ_download_get()
,
occ_download_list()
,
occ_download_meta()
,
occ_download_queue()
,
occ_download_wait()
,
occ_download()
if (FALSE) {
# 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)
}
Run the code above in your browser using DataLab