sp_occurrence: Download species occurrence data from GBIF

View source: R/occurrence.R

sp_occurrenceR Documentation

Download species occurrence data from GBIF

Description

Download data from the Global Biodiversity Information Facility (GBIF) data portal.

sp_genus returns a data.frame with all the species names associated with a genus.

sp_occurrence downloads species occurrence records. You can download data for a single species or for an entire genus by using species="". Note that the maximum number of records that can be downloaded for a single search is 100,000.

You can check the number of records returned by using the option download=FALSE.

To avoid getting more than 100,000 records, you can do separate queries for different geographic areas. If you want to download data for an entire genus, first run sp_genus and then download data for the returned species names one by one.

Before using this function, please first check the GBIF data use agreement and see the note below about how to cite these data.

Usage

sp_genus(genus, simple=TRUE, ...)

sp_occurrence(genus, species="", ext=NULL, args=NULL, geo=TRUE, removeZeros=FALSE,
        download=TRUE, ntries=5, nrecs=300, start=1, end=Inf, fixnames=TRUE, ...)

Arguments

genus

character. genus name

species

character. species name. Use '*' to download the entire genus. Append '*' to the species name to get all naming variants (e.g. with and witout species author name) and sub-taxa

ext

Extent object to limit the geographic extent of the records. An extent can be created using functions like ext and draw

args

character. Additional arguments to refine the query. See query parameters in http://www.gbif.org/developer/occurrence for more details

geo

logical. If TRUE, only records that have a georeference (longitude and latitude values) will be downloaded

removeZeros

logical. If TRUE, all records that have a latitude OR longitude of zero will be removed if geo==TRUE, or set to NA if geo==FALSE. If FALSE, only records that have a latitude AND longitude that are zero will be removed or set to NA

download

logical. If TRUE, records will be downloaded, else only the number of records will be shown

ntries

integer. How many times should the function attempt to download the data, if an invalid response is returned (perhaps because the GBIF server is very busy)

nrecs

integer. How many records to download in a single request (max is 300)?

start

integer. Record number from which to start requesting data

end

integer. Last record to request

fixnames

If TRUE a few unwieldy and poorly chosen variable names are changed as follows. "decimalLatitude" to "lat", "decimalLongitude" to "lon", "stateProvince" to "adm1", "county" to "adm2", "countryCode" to "ISO2". The names in "country" are replaced with the common (short form) country name, the original values are stored as "fullCountry"

simple

logical. If TRUE, a vector the accepted species names are returned. Otherwise a data.frame with much more information is returned

...

additional arguments passed to download.file

Value

data frame

Note

Under the terms of the GBIF data user agreement, users who download data agree to cite a DOI. Citation rewards data-publishing institutions and individuals and provides support for sharing open data [1][2]. You can get a DOI for the data you downloaded by creating a "derived" dataset. For this to work, you need to keep the "datasetKey" variable in your dataset.

References

https://www.gbif.org/occurrence https://www.gbif.org/derived-dataset/about

Examples

## Not run: 

sp_occurrence("solanum", download=FALSE)
sp_occurrence("solanum", "acaule", download=FALSE)

sp_occurrence("Batrachoseps", "" , down=FALSE)
sp_occurrence("Batrachoseps", "luciae", down=FALSE)
g <- sp_occurrence("Batrachoseps", "luciae", geo=TRUE)
plot(g$lon, g$lat)

gs <- sp_occurrence("Batrachoseps", "luciae")
plot(gs)

## End(Not run)

geodata documentation built on Dec. 1, 2022, 5:12 p.m.