Given a matrix of quadrature points and a list of species presences, this function extracts environmental data to presence locations using bilinear interpolation.
getEnvVar(sp.xy, env.grid, env.scale, coord = c("X", "Y"), envfilename = "SpEnvData",
tol = 0.01, writefile = TRUE)
A matrix containing locations of species presences in the first two columns and the interpolated environmental data in the remaining columns.
A matrix of species locations containing at least one column representing longitude and one column representing latitude.
The geo-referenced matrix of environmental grids.
The spatial resolution of the quadrature scheme from which the environmental data is extracted.
A vector containing the names of the longitude and latitude coordinates,
as in sampleQuad
.
An optional argument containing the name of the saved file. Setting
envfilename =
"SpEnvData"
will save a matrix sp.dat
containing the species presence
locations and the interpolated environmental data to the file "SpEnvData.RData"
.
An optional argument to specify the tolerance level of coordinate error passed to an internal call to the griddify
function, set to 0.01 by default.
A logical argument to determine whether the output should be written to a file or not. If TRUE
(the default), the output will be saved with the file name as described in the envfilename
argument.
Ian W. Renner
At a given species location with coordinates \((x, y)\), the interpolated value of the
environmental variable \(z\) is calculated as a weighted average of \(z\) at four reference
quadrature points \((x^{(1)}, y^{(1)})\), \((x^{(1)}, y^{(2)})\), \((x^{(2)}, y^{(1)})\) and \((x^{(2)}, y^{(2)})\)
that form a square of nominated side length env.scale
surrounding \((x, y)\).
data(BlueMountains)
species.env = getEnvVar(BlueMountains$eucalypt, env.grid = BlueMountains$env, env.scale = 0.5,
envfilename = NA, writefile = FALSE)
Run the code above in your browser using DataLab