Seach and retrieve data from the Global Biodiverity Information Facilty (GBIF)
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.
Install from CRAN
install.packages("rgbif")
Or install the development version from GitHub
remotes::install_github("ropensci/rgbif")
Load rgbif
Search by type of record, all observational in this case
occ_count(basisOfRecord='OBSERVATION')
#> [1] 18458993
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] 7367
All georeferenced records in GBIF
occ_count(georeferenced=TRUE)
#> [1] 1550522220
Records from Denmark
denmark_code <- isocodes[grep("Denmark", isocodes$name), "code"]
occ_count(country=denmark_code)
#> [1] 43218754
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] 62376904
Records for a particular dataset, and only for preserved specimens
occ_count(datasetKey='e707e6da-e143-445d-b41d-529c4a777e8b', basisOfRecord='OBSERVATION')
#> [1] 0
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 2077
head(out$data)
#> # A tibble: 6 x 25
#> key scientificName datasetKey nubKey parentKey parent canonicalName
#> <int> <chr> <chr> <int> <int> <chr> <chr>
#> 1 1.14e8 Mammalia bd0a2b6d-… 359 114079410 Anima… Mammalia
#> 2 1.52e8 Mammalia 10608bbc-… 359 152172480 Chord… Mammalia
#> 3 1.52e8 Mammalia 97b48148-… 359 152168085 Chord… Mammalia
#> 4 1.23e8 Mammalia 90d9e8a6-… 359 123221530 Gnath… Mammalia
#> 5 1.50e8 Mammalia f2faaa4c-… 359 149678160 Chord… Mammalia
#> 6 1.35e8 Mammalia bc1a1eb3-… 359 134993150 Chord… Mammalia
#> # … with 18 more variables: authorship <chr>, nameType <chr>,
#> # taxonomicStatus <chr>, origin <chr>, numDescendants <int>,
#> # numOccurrences <int>, habitats <lgl>, nomenclaturalStatus <lgl>,
#> # threatStatuses <chr>, synonym <lgl>, kingdom <chr>, phylum <chr>,
#> # kingdomKey <int>, phylumKey <int>, classKey <int>, rank <chr>, class <chr>,
#> # taxonID <chr>
out$facets
#> NULL
out$hierarchies[1:2]
#> $`114079693`
#> rankkey name
#> 1 114079410 Animalia
#>
#> $`152172481`
#> rankkey name
#> 1 152172479 Animalia
#> 2 152172480 Chordata
out$names[2]
#> $<NA>
#> NULL
Search for a genus
z <- name_lookup(query='Cnaemidophorus', rank="genus")
z$data
#> # A tibble: 24 x 35
#> key scientificName datasetKey parentKey parent kingdom phylum order family
#> <int> <chr> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 1.24e8 Cnaemidophorus fab88965-… 104446806 Ptero… Metazoa Arthr… Lepi… Ptero…
#> 2 1.58e8 Cnaemidophorus 4cec8fef-… 157904443 Ptero… Animal… Arthr… Lepi… Ptero…
#> 3 1.69e8 Cnaemidophorus 4b3e4a71-… 168525701 Ptero… Animal… Arthr… Lepi… Ptero…
#> 4 1.59e8 Cnaemidophorus 23905003-… 159439401 Ptero… Animal… Arthr… Lepi… Ptero…
#> 5 1.77e8 Cnaemidophorus 16c3f9cb-… 100557623 Ptero… <NA> <NA> Lepi… Ptero…
#> 6 1.77e8 Cnaemidophorus 4dd32523-… 177104950 Ptero… Animal… Arthr… Lepi… Ptero…
#> 7 1.77e8 Cnaemidophorus 848271aa-… 177132660 Lepid… Animal… <NA> Lepi… <NA>
#> 8 1.77e8 Cnaemidophorus cbb6498e-… 176943160 Ptero… Animal… Arthr… Lepi… Ptero…
#> 9 1.23e8 Cnaemidophoru… 90d9e8a6-… 123394987 Ptero… Animal… Arthr… Lepi… Ptero…
#> 10 1.77e8 Cnaemidophoru… 38e1da4f-… 177131894 Ptero… Animal… Arthr… Lepi… Ptero…
#> # … with 14 more rows, and 26 more variables: genus <chr>, kingdomKey <int>,
#> # phylumKey <int>, classKey <int>, orderKey <int>, familyKey <int>,
#> # genusKey <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>, nubKey <int>,
#> # authorship <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 25
#> key scientificName datasetKey nubKey parentKey parent canonicalName
#> <int> <chr> <chr> <int> <int> <chr> <chr>
#> 1 1.14e8 Mammalia bd0a2b6d-… 359 114079410 Anima… Mammalia
#> 2 1.52e8 Mammalia 10608bbc-… 359 152172480 Chord… Mammalia
#> 3 1.52e8 Mammalia 97b48148-… 359 152168085 Chord… Mammalia
#> 4 1.23e8 Mammalia 90d9e8a6-… 359 123221530 Gnath… Mammalia
#> 5 1.50e8 Mammalia f2faaa4c-… 359 149678160 Chord… Mammalia
#> 6 1.35e8 Mammalia bc1a1eb3-… 359 134993150 Chord… Mammalia
#> 7 1.55e8 Mammalia 7438332f-… 359 154531452 Chord… Mammalia
#> 8 1.59e8 Mammalia 45aeea93-… 359 158964490 Chord… Mammalia
#> 9 1.60e8 Mammalia e1f7fc27-… 359 159542105 Chord… Mammalia
#> 10 1.59e8 Mammalia eba383bf-… 359 159450483 Chord… Mammalia
#> # … with 90 more rows, and 18 more variables: authorship <chr>, nameType <chr>,
#> # taxonomicStatus <chr>, origin <chr>, numDescendants <int>,
#> # numOccurrences <int>, habitats <lgl>, nomenclaturalStatus <lgl>,
#> # threatStatuses <chr>, synonym <lgl>, kingdom <chr>, phylum <chr>,
#> # kingdomKey <int>, phylumKey <int>, classKey <int>, rank <chr>, class <chr>,
#> # taxonID <chr>
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 an… 29d2d5a6-… 9206251 168341218 Aster… Plantae Trach…
#> 2 1.28e8 Helianthus an… 41c06f1a-… 9206251 146770884 Amara… Plantae <NA>
#> 3 1.15e8 Helianthus an… ee2aac07-… 9206251 144238801 Helia… Plantae Trach…
#> 4 1.35e8 Helianthus an… f82a4f7f-… 9206251 167773411 Aster… Plantae Trach…
#> 5 1.46e8 Helianthus an… 3f5e930b-… 9206251 157140516 Helia… Plantae Angio…
#> 6 1.03e8 Helianthus an… fab88965-… NA 103340270 Helia… Viridi… Strep…
#> 7 1.63e8 Helianthus an… 88217638-… 9206251 163398972 Aster… Plantae Trach…
#> 8 1.46e8 Helianthus an… 6a97172b-… 9206251 147653302 Helia… <NA> <NA>
#> 9 1.60e8 Helianthus an… 39f36f10-… 9206251 164560273 Helia… Plantae Magno…
#> 10 1.35e8 Helianthus an… 85183816-… 9206251 167772928 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>, authorship <chr>, genus <chr>, genusKey <int>,
#> # acceptedKey <int>, accepted <chr>, publishedIn <chr>, accordingTo <chr>,
#> # constituentKey <chr>, basionymKey <int>, basionym <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 ACCEP… 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: 33 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 8951716 Puma concolor borbensis SUBSPECIES
#> 5 6164624 Puma concolor costaricensis SUBSPECIES
#> 6 6164603 Puma concolor missoulensis SUBSPECIES
#> 7 6164589 Puma concolor anthonyi SUBSPECIES
#> 8 7193927 Puma concolor concolor SUBSPECIES
#> 9 6164591 Puma concolor kaibabensis SUBSPECIES
#> 10 9156584 Puma concolor patagonica SUBSPECIES
#> # … with 23 more rows
#>
#> $hierarchy
#> list()
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,colmano,inmano
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,colmano,inmano
#>
#>
#> [[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
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 [19516]
#> 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 78
#> key scientificName decimalLatitude decimalLongitude issues datasetKey
#> <chr> <chr> <dbl> <dbl> <chr> <chr>
#> 1 3017… Ursus america… 34.5 -120. cdrou… 50c9509d-…
#> 2 3017… Ursus america… 41.9 -73.5 cdrou… 50c9509d-…
#> 3 3017… Ursus america… 38.4 -122. cdrou… 50c9509d-…
#> 4 3018… Ursus america… 37.5 -120. cdrou… 50c9509d-…
#> 5 3018… Ursus america… 37.5 -120. cdrou… 50c9509d-…
#> 6 3018… Ursus america… 42.7 -72.3 cdrou… 50c9509d-…
#> 7 3018… Ursus america… 41.9 -73.6 cdrou… 50c9509d-…
#> 8 2543… Ursus america… 42.5 -73.2 cdrou… 50c9509d-…
#> 9 2550… Ursus america… 35.7 -83.5 cdrou… 50c9509d-…
#> 10 2550… Ursus america… 31.3 -110. cdrou… 50c9509d-…
#> 11 2550… Ursus america… 35.1 -118. cdrou… 50c9509d-…
#> 12 2550… Ursus america… 25.2 -101. cdrou… 50c9509d-…
#> 13 2550… Ursus america… 39.4 -120. cdrou… 50c9509d-…
#> 14 2557… Ursus america… 43.8 -72.6 gass8… 50c9509d-…
#> 15 2557… Ursus america… 34.0 -92.6 cdrou… 50c9509d-…
#> 16 2557… Ursus america… 34.0 -92.6 cdrou… 50c9509d-…
#> 17 2557… Ursus america… 34.0 -92.6 cdrou… 50c9509d-…
#> 18 2557… Ursus america… 46.1 -87.4 cdrou… 50c9509d-…
#> 19 2563… Ursus america… 34.4 -118. cdrou… 50c9509d-…
#> 20 2563… Ursus america… 35.9 -121. cdrou… 50c9509d-…
#> # … with 72 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>,
#> # 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>, gbifID <chr>,
#> # verbatimLocality <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')$key[1]
occ_search(taxonKey=key, limit=20)
#> Records found [1650859425]
#> Records returned [20]
#> No. unique hierarchies [19]
#> No. media records [20]
#> No. facets [0]
#> Args [limit=20, offset=0, fields=all]
#> # A tibble: 20 x 81
#> key scientificName decimalLatitude decimalLongitude issues datasetKey
#> <chr> <chr> <dbl> <dbl> <chr> <chr>
#> 1 1135… Cryptosphaeri… 48.0 16.5 colma… 0afba960-…
#> 2 1632… Belenois java… -34.9 139. txmat… fa375330-…
#> 3 1632… Belenois java… -34.9 139. txmat… fa375330-…
#> 4 1830… Lopadostoma g… 48.0 16.5 colma… 0afba960-…
#> 5 1830… Platystomum o… 48.0 16.5 colma… 0afba960-…
#> 6 1831… Trechispora f… 48.0 16.5 colma… 0afba960-…
#> 7 1831… Nemania serpe… 48.0 16.5 colma… 0afba960-…
#> 8 1897… Anisotome aro… -38.9 175. cdrou… 83ae84cf-…
#> 9 1897… Lagenifera Ca… -38.9 175. cdrou… 83ae84cf-…
#> 10 1897… Aciphylla hec… -45.5 169. cdrou… 83ae84cf-…
#> 11 1897… Ozothamnus va… -39.2 175. cdrou… 83ae84cf-…
#> 12 1897… Huperzia aust… -39.2 175. cdrou… 83ae84cf-…
#> 13 1897… Isolepis auck… -39.3 176. mulur… 83ae84cf-…
#> 14 1897… Celmisia dens… -45.5 169. cdrou… 83ae84cf-…
#> 15 1897… Schizaea aust… -39.2 175. cdrou… 83ae84cf-…
#> 16 1897… Ourisia macro… -39.2 175. cdrou… 83ae84cf-…
#> 17 1897… Epilobium als… -39.2 175. cdrou… 83ae84cf-…
#> 18 1897… Lycopodium fa… -39.2 175. cdrou… 83ae84cf-…
#> 19 1897… Hebe tetragon… -38.9 175. cdrou… 83ae84cf-…
#> 20 1897… Hebe odora (H… -39.2 175. cdrou… 83ae84cf-…
#> # … with 75 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>, infraspecificEpithet <chr>, taxonRank <chr>,
#> # taxonomicStatus <chr>, elevation <dbl>, year <int>, month <int>, day <int>,
#> # eventDate <chr>, lastInterpreted <chr>, license <chr>, identifiers <chr>,
#> # facts <chr>, relations <chr>, institutionKey <chr>, isInCluster <lgl>,
#> # geodeticDatum <chr>, class <chr>, countryCode <chr>, recordedByIDs <chr>,
#> # identifiedByIDs <chr>, country <chr>, identifier <chr>, recordedBy <chr>,
#> # catalogNumber <chr>, institutionCode <chr>, locality <chr>, gbifID <chr>,
#> # collectionCode <chr>, occurrenceID <chr>, identifiedBy <chr>, name <chr>,
#> # X.99d66b6c.9087.452f.a9d4.f15f2c2d0e7e. <chr>,
#> # coordinateUncertaintyInMeters <dbl>, stateProvince <chr>, references <chr>,
#> # eventID <chr>, dataGeneralizations <chr>, vernacularName <chr>,
#> # otherCatalogNumbers <chr>, taxonConceptID <chr>, modified <chr>,
#> # collectionKey <chr>, higherGeography <chr>, language <chr>,
#> # verbatimLocality <chr>, type <chr>, verbatimElevation <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] 1650859425
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 [19516]
#> 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)$key[1], USE.NAMES=FALSE)
occ_search(taxonKey=keys, limit=5)
#> Records found [NULL (1650859425), NULL (1650859425), NULL (1650859425)]
#> Records returned [NULL (5), NULL (5), NULL (5)]
#> No. unique hierarchies [NULL (4), NULL (4), NULL (4)]
#> No. media records [NULL (5), NULL (5), NULL (5)]
#> No. facets [NULL (0), NULL (0), NULL (0)]
#> Args [limit=5, offset=0, taxonKey=NULL,NULL,NULL, fields=all]
#> 3 requests; First 10 rows of data from NULL
#>
#> # A tibble: 5 x 74
#> key scientificName decimalLatitude decimalLongitude issues datasetKey
#> <chr> <chr> <dbl> <dbl> <chr> <chr>
#> 1 1135… Cryptosphaeri… 48.0 16.5 colma… 0afba960-…
#> 2 1632… Belenois java… -34.9 139. txmat… fa375330-…
#> 3 1632… Belenois java… -34.9 139. txmat… fa375330-…
#> 4 1830… Lopadostoma g… 48.0 16.5 colma… 0afba960-…
#> 5 1830… Platystomum o… 48.0 16.5 colma… 0afba960-…
#> # … with 68 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>, infraspecificEpithet <chr>, taxonRank <chr>,
#> # taxonomicStatus <chr>, elevation <dbl>, year <int>, month <int>, day <int>,
#> # eventDate <chr>, lastInterpreted <chr>, license <chr>, identifiers <chr>,
#> # facts <chr>, relations <chr>, institutionKey <chr>, isInCluster <lgl>,
#> # geodeticDatum <chr>, class <chr>, countryCode <chr>, recordedByIDs <chr>,
#> # identifiedByIDs <chr>, country <chr>, identifier <chr>, recordedBy <chr>,
#> # catalogNumber <chr>, institutionCode <chr>, locality <chr>, gbifID <chr>,
#> # collectionCode <chr>, occurrenceID <chr>, identifiedBy <chr>, name <chr>,
#> # X.99d66b6c.9087.452f.a9d4.f15f2c2d0e7e. <chr>,
#> # coordinateUncertaintyInMeters <dbl>, stateProvince <chr>, references <chr>,
#> # eventID <chr>, dataGeneralizations <chr>, vernacularName <chr>,
#> # otherCatalogNumbers <chr>, taxonConceptID <chr>