The goal is to obtain the value(s) of one or more spatial covariates
for each point (i.e. row) in object
. The procedure depends on
the data source spatialdata
, which may be either a spatial
coverage (raster or polygon) or an object with covariate values at
points (another mask or traps object). In the first case, an
overlay operation is performed to find the pixel or
polygon matching each point. In the second case, a search is conducted
for the closest point in spatialdata
.
If spatialdata
is a character value then it is interpreted as
the name of a polygon shape file (excluding `.shp').
If spatialdata
is a SpatialPolygonsDataFrame,
SpatialGridDataFrame or 'sf' object from sf then it will be used
in an overlay operation as described.
If package terra has been installed then spatialdata
may also be a RasterLayer from package raster or SpatRaster from terra. If provided counts
should be a single name that will be used for the values (otherwise 'raster' will be used).
If spatialdata
is a mask
or traps
object then it
is searched for the closest point to each point in object
, and
covariates are drawn from the corresponding rows in
covariates(spatialdata)
. By default (strict = FALSE
),
values are returned even when the points lie outside any cell of the mask.