DownloadGBIF: Download GBIF data

Description Usage Arguments Value Note Examples

View source: R/DownloadGBIF.R

Description

This function retrieves GBIF data in SIMPLE_CSV for a user provided taxon key and area, the latter either as a ISO2 country code or a SpatialPolygons* object in WGS84 (EPSG: 4326) projection. When area is defined by a SpatialPolygons* object, records for the entire extent of the shapefile are retrieved.

Usage

1
DownloadGBIF(key, user, user.email, pwd, country, custom.shp)

Arguments

key

a gbif taxon key obtained through the rgbif::name_backbone function. Required

user

your GBIF account user name. Required.

user.email

your GBIF account email. Required.

pwd

your GBIF password. Required.

country

ISO2 code of the coutry to download data from.

custom.shp

a SpatialPolygons* object to download data from. Ignored if country is not NULL.

Value

a list with:

occ.table

Occurrence table for the defined taxon key and area

citation

The citation of your GBIF download

Note

By default this function will sample at random 2 million records for files with more than 2 milion rows. Change the default n.max and subset.size to change this behavior.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
library(raster)
library(rgbif)
library(WhereNext)

#Example 1: Get occurrence data for colombian bats by country code
gbif.key <- name_backbone(name = "Chiroptera")
gbif.res <- DownloadGBIF(gbif.key$orderKey, "your username", "your email", "your password", "CO") #Enter your GBIF credentials here

#Example2: Get occurrence data for bats from the Antioquia province in Colombia by using a shapefile
col.shp <- getData(name="GADM",country="CO", level=1) #Get country shapefile with level 1 administrative boundaries
antioquia <- col.shp[2, ]
gbif.res <- DownloadGBIF(gbif.key$orderKey, "your username", "your email", "your password", NULL, antioquia)

#Refine data to input shapefile
ind.nna<- !is.na(extract(antioquia, gbif.res$occ.table[,c("decimalLongitude", "decimalLatitude")])$poly.ID)
occ.table <- gbif.res$occ.table[ind.nna, ]
plot(antioquia)
points(occ.table$decimalLongitude, occ.table$decimalLatitude)

## End(Not run)

jivelasquezt/WhereNext-Pkg documentation built on Oct. 11, 2021, 9:46 p.m.