Description Usage Arguments Value See Also Examples
Randomly sample n
pseudo-absence points at pixels of raster
(excluding NA
pixels). If prob = TRUE
the is assumed to be a bias grid and the random sampling is weighted toward pixels with the greatest value. If spatial = TRUE
a SpatialPoints
object is returned, else a matrix of coordinates.
1 |
raster |
The raster from which to sample at random. |
n |
The number of pseudo-absence points to sample. |
prob |
Whether to weight samples by the values of the pixels in |
replace |
Whether to sample with replacement. |
spatial |
Whether to return a |
Either a SpatialPoints
object or a matrix of coordinates.
sample
, bgDistance
, 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 | # load a test raster
r <- raster(system.file("external/test.grd", package="raster"))
# randomly sample 10000 background points without replacement
pts <- bgSample(r, n = 1000)
# plot the raster
plot(r)
# the pseudo-absences (with transparency)
plot(pts, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
# this time with replacement
pts <- bgSample(r, n = 1000, replace = TRUE)
plot(r)
plot(pts, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
# now with replacement and biased by the values of the raster
pts <- bgSample(r, n = 1000, replace = TRUE, prob = TRUE)
plot(r)
plot(pts, add = TRUE, pch = 16, cex = 0.8, col = rgb(0, 0, 0, 0.2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.