gdistance: costDistance with barriers
Karl, You are using a default RasterLayer which has lon/lat coordinates. In that case the earth is considered spherical (or similar), not a plane. The maximum possible distance in longitude is 180 degrees, and the distance between -120 and 120 is not 240 degrees, but 60+60= 120 degrees, . To get the results I think you expected, use a planar CRS. For example r <- raster(nrows=18, ncols=36, crs='+proj=utm +zone=10') Robert
On Thu, Mar 12, 2015 at 11:35 AM, karljarvis <karljarvis at gmail.com> wrote:
Hi all, I am seeing confusing behavior from the costDistance function in gdistance. In general, when cost is constant, cost distance increases linearly with actual distance. However, in this example, it is not doing that for the longest few distances. Am I missing something? Karl r <- raster(nrows=18, ncols=36) r[] <- 1 t <- transition(r,function(x) 1/mean(x),4) p <- cbind(seq(-120,120,by=40),rep(0,7)) costDistance(t,p)
costDistance(t,p)
1 2 3 4 5 6 2 4 3 8 4 4 12 8 4 5 16 12 8 4 6 16 16 12 8 4 7 12 16 16 12 8 4 -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/gdistance-costDistance-with-barriers-tp7587891.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo