#Create TransitionLayer
r <- raster(ncol=36,nrow=18)
r <- setValues(r,rep(1,times=ncell(r)))
tr <- transition(r,mean,directions=4)
#Two different types of correction are required
trR <- geoCorrection(tr, type="r", multpl=FALSE)
trC <- geoCorrection(tr, type="c", multpl=FALSE)
#Create TransitionStack
ts <- stack(trR, trR)
#Points for origin and coordinates between which to calculate path (non)overlaps
sP0 <- SpatialPoints(cbind(0,0))
sP1 <- SpatialPoints(cbind(c(65,5,-65),c(-55,35,-35)))
#Randomised shortest paths
#rescaling is needed: exp(-theta * trC) should give reasonable values
trC <- trC / median(transitionMatrix(trC)@x) #divide by median of the non-zero values
pathInc(trC, origin=sP0, fromCoords=sP1, type=c("divergent","joint"), theta=2)
#Random walk
pathInc(trR, origin=sP0, fromCoords=sP1, type=c("divergent","joint"))
#TransitionStack as weights
pathInc(trR, origin=sP0, fromCoords=sP1, type=c("divergent","joint"), weight=ts)
Run the code above in your browser using DataLab