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 the BISON database from R.
# install.packages("devtools"); library(devtools); install_github("rbison", "ropensci") library(rgbif); library(XML); library(RCurl); library(plyr); library(ggplot2); library(maps)
# Test the function for a few networks networks(maxresults=5) # By name networks('ORNIS')
# Test the function for a few providers providers(maxresults=5) # By data provider name providers('University of Texas-Austin')
# Test the function for a few resources resources(maxresults=5) # By name head(resources('Flora'))
occurrencecount(scientificname = 'Accipiter erythronemius', coordinatestatus = TRUE) occurrencecount(scientificname = 'Helianthus annuus', coordinatestatus = TRUE, year=2005, maxlatitude=20)
taxrank()
taxoncount(scientificname = 'Puma concolor') taxoncount(scientificname = 'Helianthus annuus') taxoncount(rank = 'family')
(out <- taxonsearch(scientificname = 'Puma concolor'))
taxonsearch(scientificname = 'Puma concolor', rank="species", maxresults=10) taxonsearch(scientificname = 'Puma concolor', rank="species", dataproviderkey=1)
occurrenceget(key = 13749100)$dataProvider$dataResources$dataResource$occurrenceRecords$TaxonOccurrence[1:10]
out <- occurrencelist(scientificname = 'Puma concolor', coordinatestatus=TRUE, maxresults=20)
Note that the default object printed from a call to occurrencelist
is a list that contains:
out
Where do you get data after a call to the occurrencelist
function? This is where gbifdata
comes in. By default a call to gbifdata
prints a minimal data.frame with just rows name, latitude, and longitude.
gbifdata(out)
Though you can get more detailed data by calling minimal=FALSE.
head( gbifdata(out, minimal=FALSE)[,1:6] )
And you can get all possible data by specifying format=darwin.
out <- occurrencelist(scientificname = 'Puma concolor', coordinatestatus=TRUE, format="darwin", maxresults=20) head( gbifdata(out, minimal=FALSE)[,1:6] )
splist <- c('Accipiter erythronemius', 'Junco hyemalis', 'Aix sponsa', 'Ceyx fallax', 'Picoides lignarius', 'Campephilus leucopogon') out <- occurrencelist_many(splist, coordinatestatus = TRUE, maxresults = 20) gbifmap_list(out)
Another example, setting scientificname="*" so we just get any species, and then mapping points only within the state of Texas in the US.
out <- occurrencelist(scientificname="*", minlatitude=30, maxlatitude=35, minlongitude=-100, maxlongitude=-95, coordinatestatus = TRUE, maxresults = 200) gbifmap_list(input=out, mapdatabase="state", region="texas", geom=geom_jitter, jitter=position_jitter(width = 0.3, height = 0.3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.