rgbif

An interface to the GBIF API for the R statistical programming environment

rgbif homepage
Map of occurrences generated using rgbif
Map of occurrences generated using rgbif

rgbif is an R package from rOpenSci that allows searching and retrieving data from GBIF. rgbif wraps R code around the GBIF API to allow you to talk to GBIF from R and access metadata, species names, and occurrences.

Installing the package in R is simple:

> install.packages("rgbif")

Once installed, rgbif allows you to easily

  • get data for single occurrences
  • retrieve multiple occurences
  • search for taxon names
  • generate maps of occurences

Full functionality is described in the rgbif tutorial.  The rgbif package is also part of the SPOCC Species Occurrence Data suite, that provides access to occurrence records from multiple databases.

Citing data retrieved via rgbif

The rgbif library includes a function, gbif_citation, that will help you properly cite the data downloaded from GBIF. To use, simply pass either a single occurrence key, a dataset key, the results of a call to the occ_search or occ_download_get functions.

Examples:

Get citation for a single occurrence, passing the occurrence key as an argument
> gbif_citation(x=1265576727)
<<rgbif citation>>
   Citation: iNaturalist.org (2017). iNaturalist Research-grade Observations.
        Occurrence Dataset https://doi.org/10.15468/ab3s5x accessed via
        GBIF.org on 2017-10-25.. Accessed from R via rgbif
        (https://github.com/ropensci/rgbif) on 2017-10-25
   Rights:
Get citation for a dataset, passing the dataset key as an argument
> gbif_citation(x='d52d01f6-7472-4dbf-9ea8-a33c343255ac')
<<rgbif citation>>
   Citation: Moeslund J E (2016). Vegetation data from protected areas in
        Denmark (§ 3 in the Danish Nature Protection Act). Version 8.1.
        Department of Bioscience, Aarhus University. Occurrence Dataset
        https://doi.org/10.15468/ar7pbr accessed via GBIF.org on 2017-10-25..
        Accessed from R via rgbif (https://github.com/ropensci/rgbif) on
        2017-10-25
   Rights:
Get citations for several occurrences in a combined search, passing the results of a call to the occ_search function:
> my_search <- occ_search(taxonKey=2440940, country='DK')
> gbif_citation(my_search)
[[1]]
<<rgbif citation>>
   Citation: Baagøe H J, Secher Jensen T, Calabuig I (2016). Atlas of Danish
        Mammals. Danish Biodiversity Information Facility. Occurrence Dataset
        https://doi.org/10.15468/r2kvnz accessed via GBIF.org on 2017-10-25..
        Accessed from R via rgbif (https://github.com/ropensci/rgbif) on
        2017-10-25
   Rights:

[[2]]
<<rgbif citation>>
   Citation: Museum für Naturkunde Berlin. MfN - Fossil vertebrates IV.
        Occurrence Dataset https://doi.org/10.15468/kneffk accessed via
        GBIF.org on 2017-10-25.. Accessed from R via rgbif
        (https://github.com/ropensci/rgbif) on 2017-10-25
   Rights:

Get citation for asynchronous downloads, passing the results of a call to the occ_download_get function:
> 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"

...

This response will also include individual citations of contributing datasets, however, the above citation containing the DOI will include references to each of these including information about which specific occurrences were included in the download.

Get citation for downloads, passing the results of a call to the occ_download_meta function:
> my_download_metadata<-occ_download_meta("0005737-171002173027117")
> gbif_citation(my_download_metadata)
$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"
...

Citations

Scott Chamberlain (2017). rgbif: Interface to the Global ‘Biodiversity’ Information Facility ‘API’. R package version 0.9.8. https://CRAN.R-project.org/package=rgbif