View source: R/sample_background_time.R
sample_background_time | R Documentation |
This function samples background points from a raster given a set of presences. The locations returned as the center points of the sampled cells, which can overlap with the presences (in contrast to pseudo-absences, see sample_pseudoabs_time). The following methods are implemented:
'random': background points randomly sampled from the region covered by the raster (i.e. not NAs).
'dist_max': background points randomly sampled from the unioned buffers of 'dist_max' from presences (distances in 'm' for lonlat rasters, and in map units for projected rasters). Using the union of buffers means that areas that are in multiple buffers are not oversampled. This is also referred to as "thickening".
'bias': background points are sampled according to a surface representing
the biased sampling effort. Note that the surface for each time step is
normalised to sum to 1;use n_per_time_step
to affect sampling effort within
each time step.
sample_background_time(
data,
raster,
n_per_time_step,
coords = NULL,
time_col = "time",
lubridate_fun = c,
method = "random",
class_label = "background",
return_pres = TRUE,
time_buffer = 0
)
data |
An |
raster |
the terra::SpatRaster, |
n_per_time_step |
number of background points to sample for each time step (i.e. a vector of length equal to the number of time steps in raster) |
coords |
a vector of length two giving the names of the "x" and "y"
coordinates, as found in |
time_col |
The name of the column with time; if time is not a lubridate
object, use |
lubridate_fun |
function to convert the time column into a lubridate object |
method |
sampling method. One of 'random', 'dist_max', or 'bias'. |
class_label |
the label given to the sampled points. Defaults to
|
return_pres |
return presences together with background in a single tibble |
time_buffer |
the buffer on the time axis around presences that defines
their effect when sampling background with method 'max_dist'. If set to
zero, presences have an effect only on the time step to which they are
assigned in |
Note that the time axis of the raster should be in POSIXct
or
Date
format, or use ‘tstep="years"’. See terra::time()
for details on
how to set the time axis.
An object of class tibble::tibble. If presences are returned, the
presence level is set as the reference (to match the expectations in the
yardstick
package that considers the first level to be the event)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.