[R-sig-Geo] Replacing values in large rasters using conditional statements

Gregovich, Dave P (DFG) dave.gregovich at alaska.gov
Wed Feb 25 22:50:20 CET 2015


Hello,
I often replace values in a raster based on values of another raster, like this:

n.row <- n.col <- 100
a <-raster(nrows=n.row,ncols=n.col)
b <- a
a[]<-rnorm(ncell(a))
b[]<-rnorm(ncell(b))
a[b > 0] <- 1

What would analogous code be that works for large rasters without running into vector size allocation problems?

Thanks kindly for any time you spend!

Dave.
__________________________________
Dave Gregovich
Research Analyst
Alaska Department of Fish and Game
Wildlife Conservation Division
Douglas, AK 99821
(907) 465-4291
dave.gregovich at alaska.gov
__________________________________


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list