Nevil,
The function 'clump' in 'raster' does this for a single value and perhaps
you can use it in a loop over all values to achieve what you are after.
Robert

library(raster)
r <- raster(ncol=10, nrow=10)
r[] <- round(runif(100)*3)
u <- unique(r)
lst <- list()
for (i in 1:length(u)) {
x <- r==u[i]
# or, for large files:
# x <- calc(r, function(x) x == u[i])
lst[[i]] <- clump(x)
}
s <- stack(lst)
layerNames(s) <- u
plot(s)





On Mon, Sep 5, 2011 at 8:52 PM, Nevil Amos <nevil.amos@gmail.com> wrote:

> Is there an equivalent of the ESRI spatial analyst "Region group"  command
> in one of the r packages that handles rasters
>
> ie function that assigns a unique id all cells of a contiguous area of the
> same value
>
> Thanks
>
> Nevil amos
>
> ______________________________**_________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>

	[[alternative HTML version deleted]]

