Hi Robert, Many thanks for this. I've just now had a chance to monkey about with this and your suggestion works - extremely helpful! Thanks again,
Jordan On 11/11/24 2:26 PM, Robert J. Hijmans wrote: > Hi Jordan, > > Not that I know of, but I will write one for the raster package. For > now, the below might work > > Best, Robert > > library(raster) > > # set up a stack with three layers > r <- raster(nr=10, nc=10) > s <- stack(sapply(1:3, function(x) setValues(r, round(runif(ncell(r)))))) > > # unique values > us <- unique(s) > > # unfortunately, raster::reclass does not for several layers at > once (something for the to do list) > # an inefficient work around > > uss <- apply(us, 1, function(x)paste(x, collapse='_')) > comb <- function(x) match(apply(x, 1, function(x)paste(x, > collapse='_')), uss) > > x <- calc(s, comb) > plot(x) > > > On Thu, Nov 24, 2011 at 8:39 AM, Jordan Chamberlin <[email protected] > <mailto:[email protected]>> wrote: > > Hello list, > > Is there something like a combine function in R? I'm thinking of > the COMBINE function in the old ArcInfo (which gives a grid of > unique cell-wise combinations of integer values in a set of input > grids). There must be something like that already written for R, > but I'm new to this, so I'm grateful for pointers in the right > direction. > > Jordan > > _______________________________________________ > R-sig-Geo mailing list > [email protected] <mailto:[email protected]> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
