extractWCdata: Extracting World Climatic Data

Description Usage Arguments Details Value Author(s) Examples

View source: R/extractWCdata.R

Description

extractWCdata returns a data frame based on specified climatic variables.

Usage

1
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

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.

Value

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

Author(s)

Zakaria Kehel, Fawzy Nawar, Bancy Ngatia, Khadija Aouzal

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)
 }

khadijaaziz/icardaFIGSr documentation built on Dec. 21, 2021, 6:38 a.m.