Estimate isotropic cost distances
cost_distances(
x,
id,
LCD = "least-cost",
resistance = NULL,
CostFun = NULL,
ngh = NULL,
mask = NULL,
threshold = NULL,
geometry_out = NULL,
bounding_circles = NULL,
least_cost.java = FALSE,
cores.java = 1,
ram.java = NULL,
pairwise = TRUE,
write_table = NULL
)object of class sf, sfc, sfg or SpatialPolygons. The shapefile must be in a projected coordinate system (number of patches > 2).
character. Column name with the patches id.
logical. If TRUE “least-cost distance” is estimated(default) else "commute-time" , analogous to the resistance distance of circuitscape, will be estimated (See, gdistance package).
raster. Raster object with resistance values (landscape friction). Consider using a range of resistance values between 1 and 10, where 10 is the maximum resistance to movement, NA should be a complete barrier.
A function to compute the cost to move between cells. The default is the conductance (isotropic cost distance): function(x) 1/x[2].
numeric. Neighbor graph (directions) for distance calculations: 4 (von Neu-mann neighbourhood), 8 (Moore neighbourhood) or 16 (king’s and knight’s moves). Default equal 8.
object of class sf, sfc, sfg or SpatialPolygons. For higher processing speed use this option to clip the resistance at the extent of the mask.
numeric. Distance threshold, pairs of nodes with a distance value above this threshold will be discarded.
numeric. Avoids the "Inf" error and corrects the "Inf" distance values when some spatial geometries are out of the resistance extent. The raster NA values will be replaced by a Resistance value that must be provided by the user using this argument, so that it is possible to calculate cost distances for all the pairs of nodes. If NULL, then a Euclidean distance will be calculated to find these distances.
numeric. If a value is entered, this will create bounding circles around pairs of core areas (recommended for speed, large resistance rasters or pixel resolution < 150 m). Buffer distances are entered in map units. Also, the function is parallelized using and furrr package and multiprocess plan, default = NULL.
logical. If TRUE then the programming language and computing platform 'java' will be used to estimate the least-cost distance USING only the FORMULA: function(x) 1/mean(x). It is necessary to have java installed. This option use the package 'graph4lg' to reduce computation times. WARNING: This function only works with integer type resistance raster (it does not accept decimals or floating point resistance).
numeric. Computer cores used to run the .jar file (see, graph4lg), default = 1.
numeric. RAM gigabytes to run the .jar file (see, graph4lg), default = NULL.
logical. If TRUE a pairwise table is returned (From, To, distance) otherwise it will be a matrix.
character. "" indicates output to the console.
cost distance matrix
The function builds on functions out of Jacob van Etten’s ’gdistance’ package.
Jacob van Etten. 2017. R Package gdistance: Distances and Routes on Geographical Grids. Journal of Statistical Software. 10.18637/jss.v076.i13
Paul Savary. 2020. R Package graph4lg: Build Graphs for Landscape Genetics Analysis. https://cran.r-project.org/web/packages/graph4lg/index.html