Skip to content

zero cost in gdistance

3 messages · karljarvis, Jacob van Etten

#
Hi all,
I'd like to find cost distances in situations were some of the cells are 0,
to compare population genetic and landscape genetic results.  For example, a
landscape with panmixis on either side of a barrier. However, when I try it
in gdistance it gives the result "Inf" throughout in the matrix.

x <- c(-5,-5,5,5)
y <- c(-5,5,-5,5)
xy <- cbind(x,y)

m0 <- matrix(0,101,101)
m0[,51] <- 1
r0 <- raster(m0)
extent(r0) <- c(-10,10,-10,10)

t0 <- transition(r0,mean,8)
g0 <- geoCorrection(t0,type="c",multpl=FALSE)
c0 <- costDistance(g0,xy)

Is there a way to do this in R? 
I've heard that there are ways of doing cost distance in GRASS - does anyone
know if GRASS can deal with 0 resistance cells?
Karl


--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/zero-cost-in-gdistance-tp7579110.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
#
Many thanks! My mistake. I hadn't read carefully enough and thought the
distinction between cost and conductance was only a difference in how
gdistance calculates matrices, but now I see I just need to invert my
matrices.

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/zero-cost-in-gdistance-tp7579110p7579132.html
Sent from the R-sig-geo mailing list archive at Nabble.com.