get_resdist {wingen} | R Documentation |
Get a matrix of resistance distances for resist_gd
Description
Create a distance matrix based on coordinates and a connectivity layer. The output is a distance matrix where rows represent cells on the landscape and columns represent individual locations on the landscape. Each value is the resistance distance between each sample and each cell calculated using the gdistance package. This matrix is used by resist_gd. If coords_only = TRUE, the result is a distance matrix for the sample coordinates only.
Usage
get_resdist(
coords,
lyr,
fact = 0,
transitionFunction = mean,
directions = 8,
geoCorrection = TRUE,
coords_only = FALSE
)
Arguments
coords |
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) |
lyr |
conductivity layer (higher values should mean greater conductivity) for generating distances. Can be either a SpatRaster or RasterLayer. |
fact |
aggregation factor to apply to |
transitionFunction |
function to calculate transition values from grid values (defaults to mean) |
directions |
directions in which cells are connected (4, 8, 16, or other), see adjacent (defaults to 8) |
geoCorrection |
whether to apply correction to account for local distances (defaults to TRUE). Geographic correction is necessary for all objects of the class Transition that are either: (1) based on a grid in a geographic (lonlat) projection and covering a large area; (2) made with directions > 4 (see geoCorrection for more details). |
coords_only |
whether to return distances only for sample coordinates |
Value
a distance matrix used by resist_gd
Examples
load_mini_ex()
distmat <- get_resdist(mini_coords, mini_lyr)