Use a friction (cost) surface to compute the cost-distance from any cell to the border of one or more target cells.
Distances are computed by summing local distances between cells, which are connected with their neighbors in 8 directions, and assuming that the path has to go through the centers of one of the neighboring raster cells.
Distances are multiplied with the friction, thus to get the cost-distance, the friction surface must express the cost per unit distance (speed) of travel.
## S4 method for signature 'SpatRaster'costDist(x, target=0, scale=1, maxiter=50, filename="",...)
Arguments
x: SpatRaster
target: numeric. value of the target cells (where to compute cost-distance to)
scale: numeric. Scale factor. The cost distance is divided by this number
maxiter: numeric. The maximum number of iterations. Increase this number if you get the warning that costDistance did not converge