Learn R Programming

icardaFIGSr (version 1.0.2)

extractWCdata: Extracting World Climatic Data

Description

extractWCdata returns a data frame based on specified climatic variables.

Usage

extractWCdata(sites, long, lat, var, res = 2.5)

Arguments

sites

object of class "data.frame" with coordinates of sites from which to extract data.

long

character. Name of column from sites with longitude.

lat

character. Name of column from sites with latitude.

var

character. Climatic variable(s) to be extracted: 'tavg', 'tmin', 'tmax', 'prec', 'bio', 'srad', 'vapr', 'wind'

res

numeric. Spatial resolution. Default 2.5

Value

An object of class "data.frame" with specified climatic variables for coordinates in sites.

Details

A grid can be created with any particular coordinates and used as input for sites (see section 'Examples'). extractWCdata will use the given coordinates to extract data from the WorldClim2.1 database. The extracted data will most likely contain NA's for sites where climatic data is not available. These should be removed or imputed before using the data to make predictions.

Examples

Run this code
# NOT RUN {
if(interactive()){
 # Create grid
 sp1 <- seq(-16, 115, length = 10)
 sp2 <- seq(25, 59, length = 10)
 sp <- expand.grid(x = sp1, y = sp2)

 # Extract data using grid
 sp.df0 <- extractWCdata(sp, long = 'x', lat = 'y', var = 'tavg')
 sp.df <- na.omit(sp.df0)
 }
# }

Run the code above in your browser using DataLab