This function is used to download occurrence records from GBIF within a year range for given taxonomic group(s) for a given area. The function requires the packages 'rgbif', 'rgdal', and 'rgeos'

gbif_records(
  groups,
  rank,
  bounds,
  years,
  yr_from = as.numeric(substr(Sys.Date(), 1, 4)),
  limit = 50000,
  genus_level = FALSE
)

Arguments

groups

A character or vector of taxonomic group names of the same taxonomic rank

rank

A character equal to the taxonomic level of the group(s) (e.g. 'class')

bounds

A shapefile of a simplified polygon that bounds the study area (e.g. outline of the Caribbean bioregion)

years

A number equal to the number of years before the present year (default) or before yr_from for which you want occurrences collected. See Details for more information.

yr_from

A number equal to the year of the most current records you want to download. The default is the current year as determined by Sys.Date(). See Details for more information.

limit

A numerical value equal to the maximum number of records wanted. See Details for more information.

genus_level

Logical. If TRUE then the records that were only identified to the genus level are returned. If FALSE, then these records are omitted

Value

A data frame with the occurrence observations of species within the taxonomic group(s). The function only returns the columns: "order", "family", "genus", "species", "eventDate", "year", "decimalLatitude", "decimalLongitude", "basisOfRecord", "occurrenceID", and "references" from the occ_search() function of the 'rgbif' package

Details

In order to download records for a certain year range, you have to specify both years and yr_from. The years argument tells the function to download all records from a specified number of years prior to yr_from. For example, if you want records from 2016 through 2018 then you would set years = 2 and yr_from = 2018. However, the default for yr_from is the year of the computer system (i.e. for most the current year). Therefore, if you only want records from two years prior through the current year, you only need to set years = 2 and nothing for years.

The default number of records returned is 50,000, and therefore, if you want all records within a certain time frame, you should check that the number of records returned does not equal the 50,000 If it does then you should set limit to a larger number. For example, if the returned data frame of records for only one taxonomic groups has nrow(df) = limit, which the default is 50,000, increase the limit to ensure all of the records are downloaded for that group. However, the maximum number of records that can be downloaded is 200,000 at a time.

Examples

if (FALSE) {

library(here)
library(rgbif)
library(rgdal)
library(rgeos)

outline<-readOGR(file.path(here(), 'data_raw', 'gis', 'Carib_Poly.shp'))

h.occ<-gbif_records(groups = c('Amphibia','Reptilia'),
                    rank = 'class',
                    years = 2,
                    bounds = outline)

}