Dear Karl,

The transition matrix does not have cost but 1/cost values. So a value of zero means an infinite resistance.

With zero conductance/permeability around the points the cells are not connected. That is why you get Inf distances, which is correct in the example you give below.


What you probably want is to have infinite or very high permeability, the opposite of what you do now.

So rather than

t0 <- transition(r0, mean, 8)


You want to do

t0 <- transition(r0, function(x) 1/mean(x), 8)


Also, take a look at the vignette to learn why gdistance does not use friction values as an input.

Best wishes,

Jacob van Etten


________________________________
 From: karljarvis <karljarvis@gmail.com>
To: r-sig-geo@r-project.org 
Sent: Monday, 28 May 2012, 19:52
Subject: [R-sig-Geo] zero cost in gdistance

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.

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
	[[alternative HTML version deleted]]

