[R-sig-Geo] finding distance from a patch

Lorenzo Cattarino l.cattarino at uq.edu.au
Wed Feb 1 00:38:34 CET 2012


Hi,

I obtained the patches (i.e., clusters of connected cells - queen's case) from a raster object. What I am trying to do is to calculate the euclidean distance between (the border of) a patch and a cell in the raster (outside the patch). What I am looking for is the minimum euclidean distance between the cell outside the patch and the patch. 

I would like to find the coordinates of the points of each patch to calculate the distance between each of those points and the cell of interest. Then I will choose the smallest value. 

require(raster)
landscape <- matrix (sample(c(1,0), 100, T), 10) 
w <- raster(landscape)
#plot(w)
patches <- clump(w)   
#windows()
#plot(patches)

Is there a function that might help doing that?

thanks 
Lorenzo


More information about the R-sig-Geo mailing list