The intent of this work is to define a buffer around a point or polygon based on information from a raster. For instance if a polygon representing a city and the raster defines how long it takes to pass through that cell (in hours for simplicities sake). I would like to construct a buffer around this city defining the maximum range that would sum up to 24 hours. Any cell can move to any other cell so long as they are moving towards the origin (The value of the origin cell is not included in the sum).
This will allow for the creation of non-uniform buffers based on environmental information rather than setting an arbitrary buffer around a polygon.
set.seed(8354) r <-raster(matrix(ncol=5,nrow=5,abs(round(rnorm(25,5,5),0)))) e <- extent(c(0,5,0,5)) extent(r) <- e plot(r) points(2.5,2.5,cex=3,pch=19)
Below the images show the initial raster and the raster "buffered" out to outward values that equal 10. The intent to to move outward from the center cell in all 8 directions summing up values as progress is made. Upon achieving 10 the buffer is set to that extent, if the value exceeds 10, the current cell limits the extent.
One challenge I can already see is counting diagonally, in one instance the value may be less than 10 and in another greater, not really sure how to get around that as of yet.
I have been looking through the
gdistance documentation as well as
accCost as seen here. The
transition function seems to be the hangup point. Much of that stems from my lack of understanding as to what this function is doing (I'll continue my reading). I've been using sum in the transitionFunction argument.
Values on the original raster
Outward summation defining buffer extent