Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Wrapper to the Global Biodiversity Information Facility API
R Other
Failed to load latest commit information.
R tidied code, added rgeos namespac eto try to fix appveyor example run…
data made gbifissues dataset an object within the package in zzz.r
inst fixed missing urls in issues vignette
man-roxygen added note about diff btw search and count services, fix #150
man updated man files for new roxygen2
tests fixed dataset_suggest test
vignettes fixed missing urls in issues vignette
.Rbuildignore .Rbuildignore vignettes/figure folder to appease cran gods
.gitignore a few tiny white space changes
.travis.yml robustr install to fix covr
DESCRIPTION bumped date and .99 version
LICENSE bumped license to 2015, fixed wrongly spelled GBIF
Makefile updated makefile for new vignette on issue cleaning, #132
NAMESPACE updated man files for new roxygen2
NEWS added key param to elevation() fxn #148
README.Rmd added cran ver badge to readme files
README.md added cran ver badge to readme files
appveyor.yml added deploy stuff to appveyor yaml
cran-comments.md

README.md

rgbif

Build Status Build status Coverage Status rstudio mirror downloads cran version

rgbif gives you access to data from GBIF via their REST API. GBIF versions their API - we are currently using v1 of their API. You can no longer use their old API in this package - see ?rgbif-defunct.

Installation

install.packages("rgbif")

Alternatively, install development version

install.packages("devtools")
devtools::install_github("ropensci/rgbif")
library("rgbif")

Note: Windows users have to first install Rtools to use devtools

Search for occurrence data

occ_search(scientificName = "Ursus americanus", limit = 50)
#> Records found [6890] 
#> Records returned [50] 
#> No. unique hierarchies [1] 
#> No. media records [50] 
#> Args [scientificName=Ursus americanus, limit=50, offset=0, fields=all] 
#> First 10 rows of data
#> 
#>                name        key decimalLatitude decimalLongitude
#> 1  Ursus americanus  891034709        29.23322       -103.29468
#> 2  Ursus americanus 1024328693        34.20990       -118.14681
#> 3  Ursus americanus  891045574        43.73511        -72.52534
#> 4  Ursus americanus  891041363        29.28284       -103.28908
#> 5  Ursus americanus 1050834838        33.11070       -107.70675
#> 6  Ursus americanus  891056344        29.27444       -103.31536
#> 7  Ursus americanus 1042823202        44.34088        -72.46131
#> 8  Ursus americanus 1024180980        34.56844       -119.16081
#> 9  Ursus americanus 1024182262        50.09019       -117.46038
#> 10 Ursus americanus 1024328712        39.51185       -120.16434
#> ..              ...        ...             ...              ...
#> Variables not shown: issues (chr), datasetKey (chr), publishingOrgKey
#>      (chr), publishingCountry (chr), protocol (chr), lastCrawled (chr),
#>      lastParsed (chr), extensions (chr), basisOfRecord (chr), taxonKey
#>      (int), kingdomKey (int), phylumKey (int), classKey (int), orderKey
#>      (int), familyKey (int), genusKey (int), speciesKey (int),
#>      scientificName (chr), kingdom (chr), phylum (chr), order (chr),
#>      family (chr), genus (chr), species (chr), genericName (chr),
#>      specificEpithet (chr), taxonRank (chr), dateIdentified (chr), year
#>      (int), month (int), day (int), eventDate (chr), modified (chr),
#>      lastInterpreted (chr), references (chr), identifiers (chr), facts
#>      (chr), relations (chr), geodeticDatum (chr), class (chr), countryCode
#>      (chr), country (chr), verbatimEventDate (chr),
#>      http...unknown.org.occurrenceDetails (chr), rights (chr),
#>      rightsHolder (chr), occurrenceID (chr), collectionCode (chr), taxonID
#>      (chr), gbifID (chr), institutionCode (chr), datasetName (chr),
#>      catalogNumber (chr), recordedBy (chr), eventTime (chr), identifier
#>      (chr), identificationID (chr), infraspecificEpithet (chr),
#>      verbatimLocality (chr), occurrenceRemarks (chr), lifeStage (chr),
#>      elevation (dbl), elevationAccuracy (dbl), continent (chr),
#>      stateProvince (chr), georeferencedDate (chr), institutionID (chr),
#>      higherGeography (chr), type (chr), georeferenceSources (chr),
#>      identifiedBy (chr), identificationVerificationStatus (chr),
#>      samplingProtocol (chr), endDayOfYear (chr), otherCatalogNumbers
#>      (chr), preparations (chr), georeferenceVerificationStatus (chr),
#>      individualID (chr), nomenclaturalCode (chr), higherClassification
#>      (chr), locationAccordingTo (chr), verbatimCoordinateSystem (chr),
#>      previousIdentifications (chr), georeferenceProtocol (chr),
#>      identificationQualifier (chr), accessRights (chr), county (chr),
#>      dynamicProperties (chr), locality (chr), language (chr),
#>      georeferencedBy (chr), informationWithheld (chr)

Or you can get the taxon key first with name_backbone(). Here, we select to only return the occurrence data.

key <- name_backbone(name='Helianthus annuus', kingdom='plants')$speciesKey
occ_search(taxonKey=key, limit=20)
#> Records found [20365] 
#> Records returned [20] 
#> No. unique hierarchies [1] 
#> No. media records [11] 
#> Args [taxonKey=3119195, limit=20, offset=0, fields=all] 
#> First 10 rows of data
#> 
#>                 name        key decimalLatitude decimalLongitude
#> 1  Helianthus annuus  922042404        -3.28140         37.52415
#> 2  Helianthus annuus  899948224         1.27890        103.79930
#> 3  Helianthus annuus  891052261        24.82589        -99.58411
#> 4  Helianthus annuus 1038317691       -43.52777        172.62544
#> 5  Helianthus annuus  922044332        21.27114         40.41424
#> 6  Helianthus annuus  922039507        50.31402          8.52341
#> 7  Helianthus annuus  998785009        44.10879          4.66839
#> 8  Helianthus annuus  899970378        32.54041       -117.08731
#> 9  Helianthus annuus  899969160        24.82901        -99.58257
#> 10 Helianthus annuus 1054796860        33.74417       -117.38556
#> ..               ...        ...             ...              ...
#> Variables not shown: issues (chr), datasetKey (chr), publishingOrgKey
#>      (chr), publishingCountry (chr), protocol (chr), lastCrawled (chr),
#>      lastParsed (chr), extensions (chr), basisOfRecord (chr), taxonKey
#>      (int), kingdomKey (int), phylumKey (int), classKey (int), orderKey
#>      (int), familyKey (int), genusKey (int), speciesKey (int),
#>      scientificName (chr), kingdom (chr), phylum (chr), order (chr),
#>      family (chr), genus (chr), species (chr), genericName (chr),
#>      specificEpithet (chr), taxonRank (chr), year (int), month (int), day
#>      (int), eventDate (chr), lastInterpreted (chr), identifiers (chr),
#>      facts (chr), relations (chr), geodeticDatum (chr), class (chr),
#>      countryCode (chr), country (chr), gbifID (chr), institutionCode
#>      (chr), catalogNumber (chr), recordedBy (chr), locality (chr),
#>      collectionCode (chr), dateIdentified (chr), modified (chr),
#>      references (chr), verbatimEventDate (chr), verbatimLocality (chr),
#>      http...unknown.org.occurrenceDetails (chr), rights (chr),
#>      rightsHolder (chr), occurrenceID (chr), taxonID (chr),
#>      occurrenceRemarks (chr), datasetName (chr), eventTime (chr),
#>      identifier (chr), identificationID (chr), county (chr), identifiedBy
#>      (chr), stateProvince (chr), recordNumber (chr), verbatimElevation
#>      (chr), georeferenceSources (chr), coordinateAccuracy (dbl), elevation
#>      (dbl), elevationAccuracy (dbl), depth (dbl), depthAccuracy (dbl)

Search for many species

Get the keys first with name_backbone(), then pass to occ_search()

splist <- c('Accipiter erythronemius', 'Junco hyemalis', 'Aix sponsa')
keys <- sapply(splist, function(x) name_backbone(name=x)$speciesKey, USE.NAMES=FALSE)
occ_search(taxonKey=keys, limit=5, hasCoordinate=TRUE)
#> Occ. found [2480598 (20), 2492010 (1925244), 2498387 (589710)] 
#> Occ. returned [2480598 (5), 2492010 (5), 2498387 (5)] 
#> No. unique hierarchies [2480598 (1), 2492010 (1), 2498387 (1)] 
#> No. media records [2480598 (1), 2492010 (5), 2498387 (2)] 
#> Args [taxonKey=2480598,2492010,2498387, hasCoordinate=TRUE, limit=5,
#>      offset=0, fields=all] 
#> First 10 rows of data from 2480598
#> 
#>                      name        key decimalLatitude decimalLongitude
#> 1 Accipiter erythronemius  920184036       -20.76029        -56.71314
#> 2 Accipiter erythronemius  920169861       -20.55244        -56.64104
#> 3 Accipiter erythronemius 1001096527       -27.58000        -58.66000
#> 4 Accipiter erythronemius 1001096518       -27.92000        -59.14000
#> 5 Accipiter erythronemius  699417490         5.26667        -60.73333
#> Variables not shown: issues (chr), datasetKey (chr), publishingOrgKey
#>      (chr), publishingCountry (chr), protocol (chr), lastCrawled (chr),
#>      lastParsed (chr), extensions (chr), basisOfRecord (chr), taxonKey
#>      (int), kingdomKey (int), phylumKey (int), classKey (int), orderKey
#>      (int), familyKey (int), genusKey (int), speciesKey (int),
#>      scientificName (chr), kingdom (chr), phylum (chr), order (chr),
#>      family (chr), genus (chr), species (chr), genericName (chr),
#>      specificEpithet (chr), taxonRank (chr), year (int), month (int), day
#>      (int), eventDate (chr), lastInterpreted (chr), identifiers (chr),
#>      facts (chr), relations (chr), geodeticDatum (chr), class (chr),
#>      countryCode (chr), country (chr), gbifID (chr), institutionCode
#>      (chr), catalogNumber (chr), recordedBy (chr), locality (chr),
#>      collectionCode (chr), modified (chr), created (chr),
#>      higherClassification (chr), associatedSequences (chr), occurrenceID
#>      (chr), identifier (chr), taxonID (chr), sex (chr), elevation (dbl),
#>      elevationAccuracy (dbl), recordNumber (chr), institutionID (chr),
#>      rights (chr), higherGeography (chr), type (chr), georeferenceSources
#>      (chr), otherCatalogNumbers (chr), bibliographicCitation (chr),
#>      verbatimEventDate (chr), preparations (chr),
#>      georeferenceVerificationStatus (chr), occurrenceRemarks (chr),
#>      accessRights (chr), datasetName (chr), verbatimElevation (chr),
#>      language (chr)

Maps

Make a simple map of species occurrences.

splist <- c('Cyanocitta stelleri', 'Junco hyemalis', 'Aix sponsa')
keys <- sapply(splist, function(x) name_backbone(name=x)$speciesKey, USE.NAMES=FALSE)
dat <- occ_search(taxonKey=keys, limit=100, return='data', hasCoordinate=TRUE)
library('plyr')
datdf <- ldply(dat)
gbifmap(datdf)

plot of chunk unnamed-chunk-8

Meta


This package is part of a richer suite called SPOCC Species Occurrence Data, along with several other packages, that provide access to occurrence records from multiple databases.


ropensci_footer

Something went wrong with that request. Please try again.