
Function to extract nearest neighbour predictor values of provided points
Source:R/utils-spatial.R
get_ngbvalue.RdThis function performs nearest neighbour matching between biodiversity observations and independent predictors, and operates directly on provided data.frames. Note that despite being parallized this function can be rather slow for large data volumes of data!
Usage
get_ngbvalue(
coords,
env,
longlat = TRUE,
field_space = c("x", "y"),
cheap = FALSE,
...
)Arguments
- coords
A
matrix,data.frameorsfobject.- env
A
data.frameobject with the predictors.- longlat
A
logicalvariable indicating whether the projection is long-lat.- field_space
A
vectorhighlight the columns from which coordinates are to be extracted (Default:c('x','y')).- cheap
A
logicalvariable whether the dataset is considered to be large and faster computation could help.- ...
other options.
Value
A data.frame with the extracted covariate data from each provided
data point.
Details
Nearest neighbour matching is done via the geodist R-package (geodist::geodist).
Note
If multiple values are of equal distance during the nearest neighbour check, then the results is by default averaged.