Generate a preview of moving window size and sample counts based on the coordinates and
parameters to be supplied to window_gd, circle_gd, or resist_gd.
The method to be used should be specified with method = "window", "circle", or "resist". For method = "window",
wdim must be specified. For method = "circle" or "resist", maxdist must be specified and
distmat can also optionally be specified.
preview_gd(
lyr,
coords,
method = "window",
wdim = 3,
maxdist = NULL,
distmat = NULL,
fact = 0,
sample_count = TRUE,
min_n = 0,
plot = TRUE
)Plots preview of window and returns SpatRaster with sample counts layer (if sample_count = TRUE)
SpatRaster or RasterLayer to slide the window across (see Details for important information about projections). For method = "resist" this should also be the conductivity layer (see resist_gd)
coordinates of samples as sf points, a two-column matrix, or a data.frame representing x and y coordinates (see Details for important information about projections)
which method to use to create preview ("window" for window_gd, "circle" for circle_gd, or "resist" for resist_gd; defaults to "window")
if method = "window", dimensions (height x width) of window; if only one value is provided, a square window is created (defaults to 3 x 3 window)
if method = "circle" or method = "resist, the maximum geographic distance used to define the neighborhood; any samples further than this distance will not be included (see get_geodist or get_resdist)
if method = "circle" or method = "resist", an optional distance matrix to be used output from either get_geodist or get_resdist, respectively. If not provided, one will be automatically calculated.
aggregation factor to apply to lyr (defaults to 0; note: increasing this value reduces computational time)
whether to create plot of sample counts for each cell (defaults to TRUE)
minimum number of samples to use in calculations (any focal cell with a window containing less than this number of samples will be assigned a value of NA)
whether to plot results (default = TRUE)
Coordinates and rasters should be in a projected (planar) coordinate system such that raster cells are of equal sizes. Therefore, spherical systems (including latitute-longitude coordinate systems) should be projected prior to use. Transformation can be performed using st_set_crs for coordinates or project for rasters (see vignette for more details).
load_mini_ex()
preview_gd(mini_lyr, mini_coords, wdim = 3, fact = 3, sample_count = TRUE, min_n = 2)
Run the code above in your browser using DataLab