Description Usage Arguments Value See Also Examples
Sample n
background points from within a region within distance
of points
(a SpatialPoints*
object)and in areas where raster
is not NA
.
The dots argument can be used to pass additional options to bgSample
. To draw a biased sample (pseudo-absences more likely to be drawn from some areas within the distance buffer than others) set raster
as the bias grid and add prob = TRUE
via the dots argument (see examples for details).
1 | bgDistance(n, points, raster, distance, ...)
|
n |
The number of pseudo-absence points to sample. |
points |
A |
raster |
A template raster giving the regions from which to sample (non-NA areas). This can optionally be a bias grid (see examples). |
distance |
The distance in map units defining the buffer zone around |
... |
Additional arguments to pass to |
A SpatialPoints
object with n
pseudo-absence points.
bgSample
, buffer
, biasGrid
, SpatialPoints
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | rm(list = ls())
# load a test raster
r <- raster(system.file("external/test.grd", package="raster"))
# find the extent
e <- extent(r)
# define some occurrence points
pts <- matrix(c(179000, 330000,
181000, 333000,
180000, 332000),
ncol = 2,
byrow = TRUE)
# build a SpatialPoints object with them
pts <- SpatialPoints(pts, r@crs)
# randomly sample 1000 background points from within 500m of presence points
# *without* replacement
pabs <- bgDistance(1000, pts, r, 500)
# plot the raster
plot(r)
# the pseudo-absences (with transparency)
plot(pabs, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
# and the presences
plot(pts, add = TRUE, pch = 16, cex = 1.5, col = 'blue')
# this time sample with replacement
pabs <- bgDistance(1000, pts, r, 500, replace = TRUE)
plot(r)
plot(pabs, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
plot(pts, add = TRUE, pch = 16, cex = 1.5, col = 'blue')
# now with replacement and biased by the values of the raster
pabs <- bgDistance(1000, pts, r ^ 2, 500, prob = TRUE, replace = TRUE)
plot(r)
plot(pabs, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
plot(pts, add = TRUE, pch = 16, cex = 1.5, col = 'blue')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.