Function Repository Resource:

GBIFSearch

Source Notebook

Search for taxa occurrences using the Global Biodiversity Information Facility (GBIF) Occurrences API

Contributed by: Jofre Espigule-Pons

ResourceFunction["GBIFSearch"][query]

gives a dataset with taxa occurrences of the specified query.

ResourceFunction["GBIFSearch"][query,prop]

gives the property prop of the specified query.

Details and Options

ResourceFunction["GBIFSearch"] utilizes GBIF's API to find occurrences of species and taxa: GBIF Occurrences API documentation page.
The query can be specified using a taxon (as a string or Entity) or by All to include all possible taxa in the search.
ResourceFunction["GBIFSearch"][query] is equivalent to ResourceFunction["GBIFSearch"][query,"Dataset"].
Supported properties by ResourceFunction["GBIFSearch"] include:
"Count"total count of taxa occurrences of the specified query
"Dataset"dataset with taxa occurrences of the specified query
ResourceFunction["GBIFSearch"] accepts the same options as Dataset.
Other options supported by ResourceFunction["GBIFSearch"] include:
MaxItems300number of occurrences to return
"FirstItem"0offset of the occurrences to return
"OccurrenceGeoRange"{{-90, 90}, {-180, 180}}geographic range of the occurrences
"OccurrenceDateRange"{DateObject[{1700}],Today}date range of the occurrences
GBIF's API has a hard limit for any query of 100,000 records. You will get an error if the FirstItem + MaxItems exceeds 100,000. To retrieve all records beyond 100,000, you should use GBIF's asynchronous download service instead.
ResourceFunction["GBIFSearch"] does not include occurrences with missing geographic coordinates.

Examples

Basic Examples (7) 

Obtain the total count of occurrences in GBIF:

In[1]:=
ResourceFunction["GBIFSearch"][All, "Count"]
Out[1]=

Obtain the occurrences of a specific taxon:

In[2]:=
ResourceFunction["GBIFSearch"][
 Entity["Species", "Species:StorenaMathematica"]]
Out[2]=

Obtain occurrences of gray wolves observed near Yellowstone National Park during a certain period of time:

In[3]:=
ResourceFunction["GBIFSearch"][ Entity["Species", "Species:CanisLupus"], "OccurrenceGeoRange" -> GeoBounds[Entity["Park", "YellowstoneNationalPark::zc6x9"]], "OccurrenceDateRange" -> {DateObject[{2017}, "Year", "Gregorian", -5.`], DateObject[{2019, 1}, "Month", "Gregorian", -5.`]} ]
Out[3]=

Obtain occurrences of gray wolves in Canada using "FirstItem" and MaxItems:

In[4]:=
ResourceFunction["GBIFSearch"][ Entity["Species", "Species:CanisLupus"], "OccurrenceGeoRange" -> GeoBounds[Entity["Country", "Canada"]], "FirstItem" -> 800 , MaxItems -> 10]
Out[4]=

Obtain the total count of species occurrences in Yellowstone National Park:

In[5]:=
ResourceFunction["GBIFSearch"][All, "Count", "OccurrenceGeoRange" -> GeoBounds[Entity["Park", "YellowstoneNationalPark::zc6x9"]] ]
Out[5]=

Obtain the total count of species occurrences in Yellowstone National Park on a specific date:

In[6]:=
ResourceFunction["GBIFSearch"][All, "Count", "OccurrenceGeoRange" -> GeoBounds[Entity["Park", "YellowstoneNationalPark::zc6x9"]], "OccurrenceDateRange" -> {DateObject[{2017, 7, 4}, "Day", "Gregorian", -5.`], DateObject[{2017, 7, 4}, "Day", "Gregorian", -5.`]} ]
Out[6]=

Obtain all species occurrences in Yellowstone National Park on a specific date:

In[7]:=
ResourceFunction["GBIFSearch"][ All, "OccurrenceGeoRange" -> GeoBounds[Entity["Park", "YellowstoneNationalPark::zc6x9"]] , "OccurrenceDateRange" -> {DateObject[{2017, 7, 4}, "Day", "Gregorian", -5.`], DateObject[{2017, 7, 4}, "Day", "Gregorian", -5.`]}]
Out[7]=

Scope (1) 

Obtain occurrences of a certain genus:

In[8]:=
ResourceFunction["GBIFSearch"][
 Entity["Species", "Genus:Canis"], "Count"]
Out[8]=
In[9]:=
ResourceFunction["GBIFSearch"][Entity["Species", "Genus:Canis"]]
Out[9]=

Options (1) 

Options from Dataset can be directly specified in GBIFSearch:

In[10]:=
ResourceFunction["GBIFSearch"][ Entity["Species", "Species:CanisLupus"], "OccurrenceGeoRange" -> GeoBounds[Entity["Park", "YellowstoneNationalPark::zc6x9"]], "OccurrenceDateRange" -> {DateObject[{2019, 1}, "Month", "Gregorian", -5.`], Today}, Background -> LightBlue ]
Out[10]=

Possible Issues (1) 

When the taxon key is not found GBIFSearch gives a message and aborts further evaluation:

In[11]:=
ResourceFunction["GBIFSearch"]["Canjs"]
Out[11]=

Neat Examples (3) 

Import sightings of gibbons in Borneo:

In[12]:=
borneoGibbons = ResourceFunction["GBIFSearch"][Entity["Species", "Genus:Hylobates"], "OccurrenceGeoRange" -> GeoBounds[Entity["Island", "Borneo"]]]
Out[12]=

Define some plotting utilities:

In[13]:=
gibbonSpeciesNames = Union@DeleteMissing@Normal@borneoGibbons[All, "Species"];
In[14]:=
positionsSpecies[species_String] := DeleteMissing@
  Normal@borneoGibbons[Select[#["Species"] == species &], "GeoPosition"]
In[15]:=
colors = Table[ColorData[3, "ColorList"][[i]], {i, 2, 7}];

Create a geographic distribution map of endangered gibbon species in Borneo island:

In[16]:=
Labeled[GeoGraphics[
  MapThread[{#1, PointSize[0.015], Opacity[0.9], Point@positionsSpecies[#2]} &, {colors, gibbonSpeciesNames}],
  GeoRange -> Entity["Island", "Borneo"],
  GeoBackground -> GeoStyling["ReliefMap", Opacity[0.8]],
  ImageSize -> 600], {SwatchLegend[colors, gibbonSpeciesNames], Style["Distribution of Borneo Gibbon Species", FontFamily -> "Helvetica", FontSize -> 26]}, {Right, Top}]
Out[16]=

Publisher

Jofre Espigule-Pons

Version History

  • 1.0.0 – 14 July 2020

Related Resources

License Information