Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gl.costdistances

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)

Arguments

landscape

a raster object coding the resistance of the landscape

locs

coordinates of the subpopulations. If a genlight object is provided coordinates are taken from @other$latlong 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).

method

defines the type of cost distance, types are "least-cost", "rSPDistance" or "commute (Circuitscape type)"

NN

number of next neighbours recommendation is 8

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

Importing and Analysing SNP and Silicodart Data Generated by Genome-Wide Restriction Fragment Analysis

v1.9.6
GPL-2
Authors
Bernd Gruber [aut, cre], Arthur Georges [aut], Jose L. Mijangos [aut], Peter J. Unmack [ctb], Oliver Berry [ctb], Lindsay V. Clark [ctb], Floriaan Devloo-Delva [ctb]
Initial release
2021-04-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.