Feedback on new downloads interface in rgbif

Downloads in rgbif (occ_download and friends) is undergoing an overhaul to support more complex queries and to properly support in queries which are not currently supported. Any feedback on the new download interface would be great. These are breaking changes for the download functions, so we’ll release a new major version of rgbif soon

See https://github.com/ropensci/rgbif/issues/362 for discussion


Install remotes::install_github("ropensci/rgbif@downloads-rework")

After installing, see ?occ_download for examples and docs.

Here’s a brief example that should run quickly:

library(rgbif)

Construct predicates (pred, pred_multi, and preds) don’t send the query to GBIF, they only construct a query statement. The default operator for pred() is =

pred("taxonKey", 3119195) # taxonKey=3119195
pred("elevation", 5000, ">") # elevation > 5000
pred("geometry", "POLYGON((-14 42, 9 38, -7 26, -14 42))")
pred_multi("taxonKey", c(2977832, 2977901, 2977966, 2977835), "in")
pred_multi("basisOfRecord", c("MACHINE_OBSERVATION", "HUMAN_OBSERVATION"), "in")
preds(pred("year", 1989, "<="), pred("year", 2000, "="))

Pass any number of predicates to occ_download() to run a download query

occ_download(pred("taxonKey", 3119195), pred("elevation", 5000, ">"))

From here it works as before …

3 Likes

Hi Scott, is it possible to also deliver a doi with a download from rgbif? Best, Niels Raes

Hi Niels,

occ_download() uses the same API as GBIF.org uses for downloads—so yes, downloads made using occ_download() in rgbif will be assigned DOIs in the same way. The gbif_citation function can be used to retrieve a recommend citation string for a download:

> my_download<-occ_download_get("0005737-171002173027117",overwrite=TRUE)
Download file size: 0.26 MB
On disk at /tmp/0005737-171002173027117.zip
> gbif_citation(my_download)
$download
[1] "GBIF Occurrence Download https://doi.org/10.15468/dl.j0ehrr Accessed from R via rgbif (https://github.com/ropensci/rgbif) on 2017-10-18"

(example from https://www.gbif.org/tool/81747/rgbif#citations)

/Daniel

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.