Skip to content
Prev 14070 / 29559 Next

patch geometry

There is a very alpha package called landscape that provides a front-end
to the FRAGSTATS code in R (http://landscape.r-forge.r-project.org/).

If you are looking for a simpler approach, consider the raster package.
I have found that functions clump() and zonal() together can do a lot of
this work.

For example:

library(raster)
## Create dummy raster for illustration
r<- raster(nrow=50, ncol=50)

## Fill randomly with integers from 0 to 9
r[]<- trunc(runif(2500)*10)

## Find patches (defined as contiguous cells of class 1)
patch<- clump(r==1)
plot(patch)

## Find the number of raster cells in each patch
## Useful if cells are of equal area
patchCells<- zonal(r, patch, "sum")

## Find the area of raster cells in each patch
patchArea<- zonal(area(r), patch, "sum")