Re: [R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread Robert J. Hijmans
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

Re: [R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread Stachelek, Joseph
=uniqueFromCells, to=uniqueToCells, mode=out, algorithm=dijkstra) -Original Message- From: R-sig-Geo [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of karljarvis Sent: Thursday, March 12, 2015 2:36 PM To: r-sig-geo@r-project.org Subject: [R-sig-Geo] gdistance: costDistance with barriers

[R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread karljarvis
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 -

Re: [R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread karljarvis
Apologies for the confusing subject line... - Karl Jarvis -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/gdistance-costDistance-with-barriers-tp7587891p7587892.html Sent from the R-sig-geo mailing list archive at Nabble.com.

Re: [R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread Jacob van Etten via R-sig-Geo
Robert is right. This example visualizes what is happening. library(gdistance)r - raster(nrows=18, ncols=36) r[] - 1x - transition(r,function(x) 1/mean(x),4)origin - c(-120,0)goal - c(120,0)sl - shortestPath(x, origin, goal)plot(raster(sl)) On Thursday, 12 March 2015, 14:50, Robert J.

Re: [R-sig-Geo] gdistance: costDistance with barriers

2015-03-12 Thread Karl Jarvis
Great! Thank you all. On Mar 12, 2015, at 4:35 PM, Jacob van Etten jacobvanet...@yahoo.com wrote: Robert is right. This example visualizes what is happening. library(gdistance) r - raster(nrows=18, ncols=36) r[] - 1 x - transition(r,function(x) 1/mean(x),4) origin - c(-120,0) goal -