Seach and retrieve data from the Global Biodiverity Information Facilty (GBIF)

About the package

rgbif is an R package to search and retrieve data from the Global Biodiverity Information Facilty (GBIF). rgbif wraps R code around the GBIF API to allow you to talk to GBIF from R.

Get rgbif

Install from CRAN

Or install the development version from GitHub

remotes::install_github("ropensci/rgbif")

Load rgbif

Number of occurrences

Search by type of record, all observational in this case

occ_count(basisOfRecord='OBSERVATION')
#> [1] 18483075

Records for Puma concolor with lat/long data (georeferened) only. Note that hasCoordinate in occ_search() is the same as georeferenced in occ_count().

occ_count(taxonKey=2435099, georeferenced=TRUE)
#> [1] 8093

All georeferenced records in GBIF

occ_count(georeferenced=TRUE)
#> [1] 1605270476

Records from Denmark

denmark_code <- isocodes[grep("Denmark", isocodes$name), "code"]
occ_count(country=denmark_code)
#> [1] 44757342

Number of records in a particular dataset

occ_count(datasetKey='9e7ea106-0bf8-4087-bb61-dfe4f29e0f17')
#> [1] 4591

All records from 2012

occ_count(year=2012)
#> [1] 63793855

Records for a particular dataset, and only for preserved specimens

occ_count(datasetKey='e707e6da-e143-445d-b41d-529c4a777e8b', basisOfRecord='OBSERVATION')
#> [1] 0

Search for taxon names

Get possible values to be used in taxonomic rank arguments in functions

taxrank()
#> [1] "kingdom"       "phylum"        "class"         "order"        
#> [5] "family"        "genus"         "species"       "subspecies"   
#> [9] "infraspecific"

name_lookup() does full text search of name usages covering the scientific and vernacular name, the species description, distribution and the entire classification across all name usages of all or some checklists. Results are ordered by relevance as this search usually returns a lot of results.

By default name_lookup() returns five slots of information: meta, data, facets, hierarchies, and names. hierarchies and names elements are named by their matching GBIF key in the data.frame in the data slot.

out <- name_lookup(query='mammalia')
names(out)
#> [1] "meta"        "data"        "facets"      "hierarchies" "names"
out$meta
#> # A tibble: 1 x 4
#>   offset limit endOfRecords count
#>    <int> <int> <lgl>        <int>
#> 1      0   100 FALSE         2341
head(out$data)
#> # A tibble: 6 x 26
#>       key scientificName datasetKey       nubKey parentKey parent kingdom phylum
#>     <int> <chr>          <chr>             <int>     <int> <chr>  <chr>   <chr> 
#> 1  1.60e8 Mammalia       677a9818-ca48-4…    359 159534408 Chord… Animal… Chord…
#> 2  1.77e8 Mammalia       a364ceb5-1864-4…    359 176575081 Chord… Animal… Chord…
#> 3  1.47e8 Mammalia       a4e57579-9638-4…    359 147439639 Chord… Animal… Chord…
#> 4  1.47e8 Mammalia       be44f76b-73cf-4…    359 147440318 Chord… Animal… Chord…
#> 5  1.64e8 Mammalia       c383b17f-e3bc-4…    359 164285181 Chord… Animal… Chord…
#> 6  1.64e8 Mammalia       00e791be-36ae-4…    359 164302487 Chord… Animal… Chord…
#> # … with 18 more variables: kingdomKey <int>, phylumKey <int>, classKey <int>,
#> #   canonicalName <chr>, authorship <chr>, nameType <chr>,
#> #   taxonomicStatus <chr>, rank <chr>, origin <chr>, numDescendants <int>,
#> #   numOccurrences <int>, habitats <chr>, nomenclaturalStatus <lgl>,
#> #   threatStatuses <chr>, synonym <lgl>, class <chr>, constituentKey <chr>,
#> #   extinct <lgl>
out$facets
#> NULL
out$hierarchies[1:2]
#> $`159534411`
#>     rankkey     name
#> 1 159534378 Animalia
#> 2 159534408 Chordata
#> 
#> $`176575082`
#>     rankkey     name
#> 1 176575080 Animalia
#> 2 176575081 Chordata
out$names[2]
#> $<NA>
#> NULL

Search for a genus

z <- name_lookup(query='Cnaemidophorus', rank="genus")
z$data
#> # A tibble: 28 x 37
#>        key scientificName datasetKey      nubKey parentKey parent kingdom phylum
#>      <int> <chr>          <chr>            <int>     <int> <chr>  <chr>   <chr> 
#>  1  1.59e8 Cnaemidophorus 23905003-5ee5… 1858636 159439401 Ptero… Animal… Arthr…
#>  2  1.58e8 Cnaemidophorus 4cec8fef-f129… 1858636 157904443 Ptero… Animal… Arthr…
#>  3  1.69e8 Cnaemidophorus 4b3e4a71-704a… 1858636 168525701 Ptero… Animal… Arthr…
#>  4  1.83e8 Cnaemidophorus 848271aa-6a4f… 1858636 182646345 Lepid… Animal… <NA>  
#>  5  1.24e8 Cnaemidophorus fab88965-e69d…      NA 104446806 Ptero… Metazoa Arthr…
#>  6  1.78e8 Cnaemidophorus 6b6b2923-0a10… 1858636 177881660 Ptero… Metazoa Arthr…
#>  7  1.82e8 Cnaemidophorus 16c3f9cb-4b19… 1858636 100557623 Ptero… <NA>    <NA>  
#>  8  1.82e8 Cnaemidophorus cbb6498e-8927… 1858636 182338678 Ptero… Animal… Arthr…
#>  9  1.83e8 Cnaemidophorus 4dd32523-a3a3… 1858636 182545750 Ptero… Animal… Arthr…
#> 10  1.80e8 Cnaemidophorus dbaa27eb-29e7… 1858636    161750 Ptero… Animal… <NA>  
#> # … with 18 more rows, and 29 more variables: order <chr>, family <chr>,
#> #   genus <chr>, kingdomKey <int>, phylumKey <int>, classKey <int>,
#> #   orderKey <int>, familyKey <int>, genusKey <int>, canonicalName <chr>,
#> #   authorship <chr>, nameType <chr>, taxonomicStatus <chr>, rank <chr>,
#> #   origin <chr>, numDescendants <int>, numOccurrences <int>, habitats <chr>,
#> #   nomenclaturalStatus <chr>, threatStatuses <chr>, synonym <lgl>,
#> #   class <chr>, taxonID <chr>, acceptedKey <int>, accepted <chr>,
#> #   constituentKey <chr>, publishedIn <chr>, extinct <lgl>, accordingTo <chr>

Search for the class mammalia

w <- name_lookup(query='mammalia')
w$data
#> # A tibble: 100 x 26
#>        key scientificName datasetKey      nubKey parentKey parent kingdom phylum
#>      <int> <chr>          <chr>            <int>     <int> <chr>  <chr>   <chr> 
#>  1  1.60e8 Mammalia       677a9818-ca48-…    359 159534408 Chord… Animal… Chord…
#>  2  1.77e8 Mammalia       a364ceb5-1864-…    359 176575081 Chord… Animal… Chord…
#>  3  1.47e8 Mammalia       a4e57579-9638-…    359 147439639 Chord… Animal… Chord…
#>  4  1.47e8 Mammalia       be44f76b-73cf-…    359 147440318 Chord… Animal… Chord…
#>  5  1.64e8 Mammalia       c383b17f-e3bc-…    359 164285181 Chord… Animal… Chord…
#>  6  1.64e8 Mammalia       00e791be-36ae-…    359 164302487 Chord… Animal… Chord…
#>  7  1.68e8 Mammalia       6b64ef7e-82f7-…    359 168337497 Chord… Animal… Chord…
#>  8  1.76e8 Mammalia       cd8ba8a5-8504-…    359 176085130 Chord… Animal… Chord…
#>  9  1.77e8 Mammalia       8901e0e4-c1b9-…    359 176574743 Chord… Animal… Chord…
#> 10  1.52e8 Mammalia       961a3a60-22ec-…    359 152056194 Chord… Animal… Chord…
#> # … with 90 more rows, and 18 more variables: kingdomKey <int>,
#> #   phylumKey <int>, classKey <int>, canonicalName <chr>, authorship <chr>,
#> #   nameType <chr>, taxonomicStatus <chr>, rank <chr>, origin <chr>,
#> #   numDescendants <int>, numOccurrences <int>, habitats <chr>,
#> #   nomenclaturalStatus <lgl>, threatStatuses <chr>, synonym <lgl>,
#> #   class <chr>, constituentKey <chr>, extinct <lgl>

Look up the species Helianthus annuus

m <- name_lookup(query = 'Helianthus annuus', rank="species")
m$data
#> # A tibble: 100 x 41
#>        key scientificName  datasetKey     nubKey parentKey parent kingdom phylum
#>      <int> <chr>           <chr>           <int>     <int> <chr>  <chr>   <chr> 
#>  1  1.35e8 Helianthus ann… f82a4f7f-6f8… 9206251 180663995 Aster… Plantae Trach…
#>  2  1.15e8 Helianthus ann… ee2aac07-de9… 9206251 144238801 Helia… Plantae Trach…
#>  3  1.46e8 Helianthus ann… 3f5e930b-52a… 9206251 157140516 Helia… Plantae Angio…
#>  4  1.35e8 Helianthus ann… 29d2d5a6-db2… 9206251 181005136 Aster… Plantae Trach…
#>  5  1.63e8 Helianthus ann… 88217638-274… 9206251 163398972 Aster… Plantae Trach…
#>  6  1.03e8 Helianthus ann… fab88965-e69…      NA 103340270 Helia… Viridi… Strep…
#>  7  1.79e8 Helianthus ann… 6b6b2923-0a1… 9206251 178978795 Helia… Viridi… Strep…
#>  8  1.28e8 Helianthus ann… 41c06f1a-23d… 9206251 146770884 Amara… Plantae <NA>  
#>  9  1.35e8 Helianthus ann… 83ca3188-af1… 9206251 180784910 Aster… Plantae Trach…
#> 10  1.35e8 Helianthus ann… 3cabcf37-db1… 9206251 168335901 Aster… Plantae Trach…
#> # … with 90 more rows, and 33 more variables: order <chr>, family <chr>,
#> #   species <chr>, kingdomKey <int>, phylumKey <int>, classKey <int>,
#> #   orderKey <int>, familyKey <int>, speciesKey <int>, canonicalName <chr>,
#> #   nameType <chr>, taxonomicStatus <chr>, rank <chr>, origin <chr>,
#> #   numDescendants <int>, numOccurrences <int>, taxonID <chr>, habitats <chr>,
#> #   nomenclaturalStatus <chr>, threatStatuses <chr>, synonym <lgl>,
#> #   class <chr>, genus <chr>, genusKey <int>, authorship <chr>,
#> #   acceptedKey <int>, accepted <chr>, publishedIn <chr>, accordingTo <chr>,
#> #   basionymKey <int>, basionym <chr>, constituentKey <chr>, extinct <lgl>

The function name_usage() works with lots of different name endpoints in GBIF, listed at https://www.gbif.org/developer/species#nameUsages

name_usage(key=3119195, language="FRENCH", data='vernacularNames')
#> Records returned [0] 
#> Args [offset=0, limit=100, language=FRENCH] 
#> # A tibble: 0 x 0

The function name_backbone() is used to search against the GBIF backbone taxonomy

name_backbone(name='Helianthus', rank='genus', kingdom='plants')
#> # A tibble: 1 x 20
#>   usageKey scientificName canonicalName rank  status   confidence matchType
#> *    <int> <chr>          <chr>         <chr> <chr>         <int> <chr>    
#> 1  3119134 Helianthus L.  Helianthus    GENUS ACCEPTED         97 EXACT    
#> # … with 13 more variables: kingdom <chr>, phylum <chr>, order <chr>,
#> #   family <chr>, genus <chr>, kingdomKey <int>, phylumKey <int>,
#> #   classKey <int>, orderKey <int>, familyKey <int>, genusKey <int>,
#> #   synonym <lgl>, class <chr>

The function name_suggest() is optimized for speed, and gives back suggested names based on query parameters.

head( name_suggest(q='Puma concolor') )
#> $data
#> # A tibble: 32 x 3
#>        key canonicalName                rank      
#>      <int> <chr>                        <chr>     
#>  1 2435099 Puma concolor                SPECIES   
#>  2 8860878 Puma concolor capricornensis SUBSPECIES
#>  3 6164618 Puma concolor browni         SUBSPECIES
#>  4 7193927 Puma concolor concolor       SUBSPECIES
#>  5 6164623 Puma concolor cabrerae       SUBSPECIES
#>  6 8944801 Puma concolor acrocodia      SUBSPECIES
#>  7 9104297 Puma concolor greeni         SUBSPECIES
#>  8 9045222 Puma concolor araucanus      SUBSPECIES
#>  9 6164608 Puma concolor californica    SUBSPECIES
#> 10 6164594 Puma concolor vancouverensis SUBSPECIES
#> # … with 22 more rows
#> 
#> $hierarchy
#> list()

Single occurrence records

Get data for a single occurrence. Note that data is returned as a list, with slots for metadata and data.

occ_get(key=855998194)
#> [[1]]
#> [[1]]$hierarchy
#>               name     key    rank
#> 1         Animalia       1 kingdom
#> 2         Chordata      44  phylum
#> 3         Mammalia     359   class
#> 4         Rodentia    1459   order
#> 5        Sciuridae    9456  family
#> 6          Sciurus 2437489   genus
#> 7 Sciurus vulgaris 8211070 species
#> 
#> [[1]]$media
#> [[1]]$media$`855998194`
#> [[1]]$media$`855998194`[[1]]
#> [[1]]$media$`855998194`[[1]][[1]]
#> [1] "none"
#> 
#> 
#> [[1]]$media$`855998194`$key
#> [1] "855998194"
#> 
#> [[1]]$media$`855998194`$species
#> [1] "Sciurus vulgaris"
#> 
#> [[1]]$media$`855998194`$decimalLatitude
#> [1] 58.40677
#> 
#> [[1]]$media$`855998194`$decimalLongitude
#> [1] 12.04386
#> 
#> [[1]]$media$`855998194`$country
#> [1] "Sweden"
#> 
#> 
#> 
#> [[1]]$data
#>         key                  scientificName decimalLatitude decimalLongitude
#> 1 855998194 Sciurus vulgaris Linnaeus, 1758        58.40677         12.04386
#>           issues
#> 1 cdround,gass84

Get many occurrences. occ_get is vectorized

occ_get(key=c(855998194, 240713150))
#> [[1]]
#> [[1]]$hierarchy
#>               name     key    rank
#> 1         Animalia       1 kingdom
#> 2         Chordata      44  phylum
#> 3         Mammalia     359   class
#> 4         Rodentia    1459   order
#> 5        Sciuridae    9456  family
#> 6          Sciurus 2437489   genus
#> 7 Sciurus vulgaris 8211070 species
#> 
#> [[1]]$media
#> [[1]]$media$`855998194`
#> [[1]]$media$`855998194`[[1]]
#> [[1]]$media$`855998194`[[1]][[1]]
#> [1] "none"
#> 
#> 
#> [[1]]$media$`855998194`$key
#> [1] "855998194"
#> 
#> [[1]]$media$`855998194`$species
#> [1] "Sciurus vulgaris"
#> 
#> [[1]]$media$`855998194`$decimalLatitude
#> [1] 58.40677
#> 
#> [[1]]$media$`855998194`$decimalLongitude
#> [1] 12.04386
#> 
#> [[1]]$media$`855998194`$country
#> [1] "Sweden"
#> 
#> 
#> 
#> [[1]]$data
#>         key                  scientificName decimalLatitude decimalLongitude
#> 1 855998194 Sciurus vulgaris Linnaeus, 1758        58.40677         12.04386
#>           issues
#> 1 cdround,gass84
#> 
#> 
#> [[2]]
#> [[2]]$hierarchy
#>            name     key    rank
#> 1     Chromista       4 kingdom
#> 2  Foraminifera 8376456  phylum
#> 3  Monothalamea 7882876   class
#> 4  Astrorhizida 8142878   order
#> 5 Astrorhizidae 7747923  family
#> 6      Pelosina 7822114   genus
#> 
#> [[2]]$media
#> [[2]]$media$`240713150`
#> [[2]]$media$`240713150`[[1]]
#> [[2]]$media$`240713150`[[1]][[1]]
#> [1] "none"
#> 
#> 
#> [[2]]$media$`240713150`$key
#> [1] "240713150"
#> 
#> [[2]]$media$`240713150`$decimalLatitude
#> [1] -77.5667
#> 
#> [[2]]$media$`240713150`$decimalLongitude
#> [1] 163.583
#> 
#> [[2]]$media$`240713150`$country
#> [1] "Antarctica"
#> 
#> 
#> 
#> [[2]]$data
#>         key       scientificName decimalLatitude decimalLongitude
#> 1 240713150 Pelosina Brady, 1879        -77.5667          163.583
#>                   issues
#> 1 gass84,ambinst,colmano

Search for occurrences

Note: The maximum number of records you can get with occ_search() and occ_data() is 100,000. See https://www.gbif.org/developer/occurrence

By default occ_search() returns a dplyr like output summary in which the data printed expands based on how much data is returned, and the size of your window. You can search by scientific name:

occ_search(scientificName = "Ursus americanus", limit = 20)
#> Records found [20895] 
#> Records returned [20] 
#> No. unique hierarchies [1] 
#> No. media records [20] 
#> No. facets [0] 
#> Args [limit=20, offset=0, scientificName=Ursus americanus, fields=all] 
#> # A tibble: 20 x 79
#>    key    scientificName   decimalLatitude decimalLongitude issues  datasetKey  
#>    <chr>  <chr>                      <dbl>            <dbl> <chr>   <chr>       
#>  1 30179… Ursus americanu…            34.5           -120.  cdroun… 50c9509d-22…
#>  2 30179… Ursus americanu…            41.9            -73.5 cdroun… 50c9509d-22…
#>  3 30179… Ursus americanu…            38.4           -122.  cdroun… 50c9509d-22…
#>  4 30180… Ursus americanu…            37.5           -120.  cdroun… 50c9509d-22…
#>  5 30180… Ursus americanu…            37.5           -120.  gass84  50c9509d-22…
#>  6 30181… Ursus americanu…            42.7            -72.3 cdroun… 50c9509d-22…
#>  7 30181… Ursus americanu…            41.9            -73.6 cdroun… 50c9509d-22…
#>  8 30317… Ursus americanu…            42.2           -123.  cdroun… 50c9509d-22…
#>  9 30317… Ursus americanu…            25.2           -101.  cdroun… 50c9509d-22…
#> 10 30318… Ursus americanu…            42.3            -72.4 cdroun… 50c9509d-22…
#> 11 30318… Ursus americanu…            42.7            -73.2 cdroun… 50c9509d-22…
#> 12 30318… Ursus americanu…            51.9           -120.  cdroun… 50c9509d-22…
#> 13 30319… Ursus americanu…            42.2           -123.  cdroun… 50c9509d-22…
#> 14 30320… Ursus americanu…            43.6            -72.6 cdroun… 50c9509d-22…
#> 15 30320… Ursus americanu…            43.4            -71.9 cdroun… 50c9509d-22…
#> 16 30321… Ursus americanu…            45.3            -84.5 cdroun… 50c9509d-22…
#> 17 30321… Ursus americanu…            34.8           -120.  cdroun… 50c9509d-22…
#> 18 30391… Ursus americanu…            29.2            -81.6 cdroun… 50c9509d-22…
#> 19 30392… Ursus americanu…            48.5           -124.  gass84  50c9509d-22…
#> 20 30393… Ursus americanu…            29.3           -103.  cdroun… 50c9509d-22…
#> # … with 73 more variables: publishingOrgKey <chr>, installationKey <chr>,
#> #   publishingCountry <chr>, protocol <chr>, lastCrawled <chr>,
#> #   lastParsed <chr>, crawlId <int>, hostingOrganizationKey <chr>,
#> #   basisOfRecord <chr>, occurrenceStatus <chr>, taxonKey <int>,
#> #   kingdomKey <int>, phylumKey <int>, classKey <int>, orderKey <int>,
#> #   familyKey <int>, genusKey <int>, speciesKey <int>, acceptedTaxonKey <int>,
#> #   acceptedScientificName <chr>, kingdom <chr>, phylum <chr>, order <chr>,
#> #   family <chr>, genus <chr>, species <chr>, genericName <chr>,
#> #   specificEpithet <chr>, taxonRank <chr>, taxonomicStatus <chr>,
#> #   iucnRedListCategory <chr>, dateIdentified <chr>,
#> #   coordinateUncertaintyInMeters <dbl>, stateProvince <chr>, year <int>,
#> #   month <int>, day <int>, eventDate <chr>, modified <chr>,
#> #   lastInterpreted <chr>, references <chr>, license <chr>, identifiers <chr>,
#> #   facts <chr>, relations <chr>, isInCluster <lgl>, geodeticDatum <chr>,
#> #   class <chr>, countryCode <chr>, recordedByIDs <chr>, identifiedByIDs <chr>,
#> #   country <chr>, rightsHolder <chr>, identifier <chr>,
#> #   http...unknown.org.nick <chr>, informationWithheld <chr>,
#> #   verbatimEventDate <chr>, datasetName <chr>, verbatimLocality <chr>,
#> #   gbifID <chr>, collectionCode <chr>, occurrenceID <chr>, taxonID <chr>,
#> #   catalogNumber <chr>, recordedBy <chr>,
#> #   http...unknown.org.occurrenceDetails <chr>, institutionCode <chr>,
#> #   rights <chr>, eventTime <chr>, occurrenceRemarks <chr>, identifiedBy <chr>,
#> #   identificationID <chr>, name <chr>

Or to be more precise, you can search for names first, make sure you have the right name, then pass the GBIF key to the occ_search() function:

key <- name_suggest(q='Helianthus annuus', rank='species')$data$key[1]
occ_search(taxonKey=key, limit=20)
#> Records found [87309] 
#> Records returned [20] 
#> No. unique hierarchies [1] 
#> No. media records [20] 
#> No. facets [0] 
#> Args [limit=20, offset=0, taxonKey=9206251, fields=all] 
#> # A tibble: 20 x 86
#>    key    scientificName  decimalLatitude decimalLongitude issues  datasetKey   
#>    <chr>  <chr>                     <dbl>            <dbl> <chr>   <chr>        
#>  1 30179… Helianthus ann…           29.4            -98.5  "cdrou… 50c9509d-22c…
#>  2 30181… Helianthus ann…          -29.6             30.4  "cdrou… 50c9509d-22c…
#>  3 30181… Helianthus ann…           50.8              4.10 "cdrou… 50c9509d-22c…
#>  4 30316… Helianthus ann…           34.3           -118.   "cdrou… 50c9509d-22c…
#>  5 30316… Helianthus ann…            3.04           102.   "cdrou… 50c9509d-22c…
#>  6 30318… Helianthus ann…           35.1           -107.   "cdrou… 50c9509d-22c…
#>  7 30319… Helianthus ann…           33.9           -117.   "cdrou… 50c9509d-22c…
#>  8 30319… Helianthus ann…          -38.0            -59.2  "cdrou… 50c9509d-22c…
#>  9 30320… Helianthus ann…            8.60           -83.4  "cdrou… 50c9509d-22c…
#> 10 30320… Helianthus ann…           44.3            -78.4  "cdrou… 50c9509d-22c…
#> 11 30320… Helianthus ann…           28.3           -105.   "cdrou… 50c9509d-22c…
#> 12 30321… Helianthus ann…          -37.4            145.   "cdrou… 50c9509d-22c…
#> 13 30321… Helianthus ann…           45.4           -114.   "cdrou… 50c9509d-22c…
#> 14 30321… Helianthus ann…           29.6            -95.1  "cdrou… 50c9509d-22c…
#> 15 30321… Helianthus ann…           50.4             33.4  "cdrou… 50c9509d-22c…
#> 16 30321… Helianthus ann…          -32.2            142.   "cdrou… 50c9509d-22c…
#> 17 30391… Helianthus ann…          -25.4            -49.2  "cdrou… 50c9509d-22c…
#> 18 30391… Helianthus ann…           NA               NA    ""      50c9509d-22c…
#> 19 30392… Helianthus ann…           22.8            -98.5  "cdrou… 50c9509d-22c…
#> 20 30393… Helianthus ann…           25.8           -109.   "cdrou… 50c9509d-22c…
#> # … with 80 more variables: publishingOrgKey <chr>, installationKey <chr>,
#> #   publishingCountry <chr>, protocol <chr>, lastCrawled <chr>,
#> #   lastParsed <chr>, crawlId <int>, hostingOrganizationKey <chr>,
#> #   basisOfRecord <chr>, occurrenceStatus <chr>, taxonKey <int>,
#> #   kingdomKey <int>, phylumKey <int>, classKey <int>, orderKey <int>,
#> #   familyKey <int>, genusKey <int>, speciesKey <int>, acceptedTaxonKey <int>,
#> #   acceptedScientificName <chr>, kingdom <chr>, phylum <chr>, order <chr>,
#> #   family <chr>, genus <chr>, species <chr>, genericName <chr>,
#> #   specificEpithet <chr>, taxonRank <chr>, taxonomicStatus <chr>,
#> #   iucnRedListCategory <chr>, dateIdentified <chr>,
#> #   coordinateUncertaintyInMeters <dbl>, stateProvince <chr>, year <int>,
#> #   month <int>, day <int>, eventDate <chr>, modified <chr>,
#> #   lastInterpreted <chr>, references <chr>, license <chr>, identifiers <chr>,
#> #   facts <chr>, relations <chr>, isInCluster <lgl>, geodeticDatum <chr>,
#> #   class <chr>, countryCode <chr>, recordedByIDs <chr>, identifiedByIDs <chr>,
#> #   country <chr>, rightsHolder <chr>, identifier <chr>,
#> #   http...unknown.org.nick <chr>, verbatimEventDate <chr>, datasetName <chr>,
#> #   verbatimLocality <chr>, gbifID <chr>, collectionCode <chr>,
#> #   occurrenceID <chr>, taxonID <chr>, catalogNumber <chr>, recordedBy <chr>,
#> #   http...unknown.org.occurrenceDetails <chr>, institutionCode <chr>,
#> #   rights <chr>, eventTime <chr>, reproductiveCondition <chr>,
#> #   identifiedBy <chr>, identificationID <chr>, name <chr>,
#> #   occurrenceRemarks <chr>, recordedByIDs.type <chr>,
#> #   recordedByIDs.value <chr>, identifiedByIDs.type <chr>,
#> #   identifiedByIDs.value <chr>, identificationRemarks <chr>, gadm <chr>,
#> #   informationWithheld <chr>

You can index to different parts of the oupu; here, the metadata:

occ_search(taxonKey=key)$meta
#> $offset
#> [1] 300
#> 
#> $limit
#> [1] 200
#> 
#> $endOfRecords
#> [1] FALSE
#> 
#> $count
#> [1] 87309

You can choose what fields to return. This isn’t passed on to the API query to GBIF as they don’t allow that, but we filter out the columns before we give the data back to you.

occ_search(scientificName = "Ursus americanus", fields=c('name','basisOfRecord','protocol'), limit = 20)
#> Records found [20895] 
#> Records returned [20] 
#> No. unique hierarchies [1] 
#> No. media records [20] 
#> No. facets [0] 
#> Args [limit=20, offset=0, scientificName=Ursus americanus,
#>      fields=name,basisOfRecord,protocol] 
#> # A tibble: 20 x 2
#>    protocol    basisOfRecord    
#>    <chr>       <chr>            
#>  1 DWC_ARCHIVE HUMAN_OBSERVATION
#>  2 DWC_ARCHIVE HUMAN_OBSERVATION
#>  3 DWC_ARCHIVE HUMAN_OBSERVATION
#>  4 DWC_ARCHIVE HUMAN_OBSERVATION
#>  5 DWC_ARCHIVE HUMAN_OBSERVATION
#>  6 DWC_ARCHIVE HUMAN_OBSERVATION
#>  7 DWC_ARCHIVE HUMAN_OBSERVATION
#>  8 DWC_ARCHIVE HUMAN_OBSERVATION
#>  9 DWC_ARCHIVE HUMAN_OBSERVATION
#> 10 DWC_ARCHIVE HUMAN_OBSERVATION
#> 11 DWC_ARCHIVE HUMAN_OBSERVATION
#> 12 DWC_ARCHIVE HUMAN_OBSERVATION
#> 13 DWC_ARCHIVE HUMAN_OBSERVATION
#> 14 DWC_ARCHIVE HUMAN_OBSERVATION
#> 15 DWC_ARCHIVE HUMAN_OBSERVATION
#> 16 DWC_ARCHIVE HUMAN_OBSERVATION
#> 17 DWC_ARCHIVE HUMAN_OBSERVATION
#> 18 DWC_ARCHIVE HUMAN_OBSERVATION
#> 19 DWC_ARCHIVE HUMAN_OBSERVATION
#> 20 DWC_ARCHIVE HUMAN_OBSERVATION

Most parameters are vectorized, so you can pass in more than one value:

splist <- c('Cyanocitta stelleri', 'Junco hyemalis', 'Aix sponsa')
keys <- sapply(splist, function(x) name_suggest(x)$data$key[1], USE.NAMES=FALSE)
occ_search(taxonKey=keys, limit=5)
#> Records found [2482598 (1241473), 9362842 (6429075), 2498387 (2228924)] 
#> Records returned [2482598 (5), 9362842 (5), 2498387 (5)] 
#> No. unique hierarchies [2482598 (1), 9362842 (1), 2498387 (1)] 
#> No. media records [2482598 (5), 9362842 (5), 2498387 (5)] 
#> No. facets [2482598 (0), 9362842 (0), 2498387 (0)] 
#> Args [limit=5, offset=0, taxonKey=2482598,9362842,2498387, fields=all] 
#> 3 requests; First 10 rows of data from 2482598
#> 
#> # A tibble: 5 x 80
#>   key    scientificName    decimalLatitude decimalLongitude issues datasetKey   
#>   <chr>  <chr>                       <dbl>            <dbl> <chr>  <chr>        
#> 1 30179… Cyanocitta stell…            49.0            -123. cdrou… 50c9509d-22c…
#> 2 30179… Cyanocitta stell…            47.7            -122. cdrou… 50c9509d-22c…
#> 3 30179… Cyanocitta stell…            37.6            -122. cdrou… 50c9509d-22c…
#> 4 30179… Cyanocitta stell…            36.8            -122. cdrou… 50c9509d-22c…
#> 5 30179… Cyanocitta stell…            50.6            -115. cdrou… 50c9509d-22c…
#> # … with 74 more variables: publishingOrgKey <chr>, installationKey <chr>,
#> #   publishingCountry <chr>, protocol <chr>, lastCrawled <chr>,
#> #   lastParsed <chr>, crawlId <int>, hostingOrganizationKey <chr>,
#> #   basisOfRecord <chr>, occurrenceStatus <chr>, taxonKey <int>,
#> #   kingdomKey <int>, phylumKey <int>, classKey <int>, orderKey <int>,
#> #   familyKey <int>, genusKey <int>, speciesKey <int>, acceptedTaxonKey <int>,
#> #   acceptedScientificName <chr>, kingdom <chr>, phylum <chr>, order <chr>,
#> #   family <chr>, genus <chr>, species <chr>, genericName <chr>,
#> #   specificEpithet <chr>, taxonRank <chr>, taxonomicStatus <chr>,
#> #   iucnRedListCategory <chr>, dateIdentified <chr>,
#> #   coordinateUncertaintyInMeters <dbl>, stateProvince <chr>, year <int>,
#> #   month <int>, day <int>, eventDate <chr>, modified <chr>,
#> #   lastInterpreted <chr>, references <chr>, license <chr>, identifiers <chr>,
#> #   facts <chr>, relations <chr>, isInCluster <lgl>, geodeticDatum <chr>,
#> #   class <chr>, countryCode <chr>, recordedByIDs <chr>, identifiedByIDs <chr>,
#> #   country <chr>, rightsHolder <chr>, identifier <chr>,
#> #   http...unknown.org.nick <chr>, verbatimEventDate <chr>, datasetName <chr>,
#> #   verbatimLocality <chr>, gbifID <chr>, collectionCode <chr>,
#> #   occurrenceID <chr>, taxonID <chr>, catalogNumber <chr>, recordedBy <chr>,
#> #   http...unknown.org.occurrenceDetails <chr>, institutionCode <chr>,
#> #   rights <chr>, eventTime <chr>, identifiedBy <chr>, identificationID <chr>,
#> #   name <chr>, occurrenceRemarks <chr>, gadm <chr>, informationWithheld <chr>

Maps

Using thet GBIF map web tile service, making a raster and visualizing it.

x <- map_fetch(taxonKey = 2480498, year = 2000:2017)
library(raster)
plot(x)