gl.costdistances: Calculates cost distances for a given landscape (resistance...

View source: R/gl.costdistances.r

gl.costdistancesR Documentation

Calculates cost distances for a given landscape (resistance matrix)

Description

Calculates a cost distance matrix, to be used with run.popgensim.

Usage

gl.costdistances(landscape, locs, method, NN, verbose = NULL)

Arguments

landscape

A raster object coding the resistance of the landscape [required].

locs

Coordinates of the subpopulations. If a genlight object is provided coordinates are taken from @other$latlon and centers for population (pop(gl)) are calculated. In case you want to calculate costdistances between individuals redefine pop(gl) via: pop(gl)<- indNames(gl) [required].

method

Defines the type of cost distance, types are 'leastcost', 'rSPDistance' or 'commute' (Circuitscape type) [required].

NN

Number of next neighbours recommendation is 8 [required].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity].

Value

A costdistance matrix between all pairs of locs.

Examples

## Not run: 
data(possums.gl)
library(raster)  #needed for that example
landscape.sim <- readRDS(system.file('extdata','landscape.sim.rdata', 
package='dartR'))
#calculate mean centers of individuals per population
xy <- apply(possums.gl@other$xy, 2, function(x) tapply(x, pop(possums.gl),
 mean))
cd <- gl.costdistances(landscape.sim, xy, method='leastcost', NN=8)
round(cd,3)

## End(Not run)

dartR documentation built on June 8, 2023, 6:48 a.m.