Skip to content
Prev 7484 / 29559 Next

"subset" a large raster object

Don,

I am guessing that you did not provide a function to rasterToPoints to
subset the values. That should work if the number of cells within the
range specified is not extremely large.

r = raster(filename, band=1)
p = rasterToPoints(r, fun=function(x){x > 21 & x < 25})


If you need to combine various bands, you could first do some raster
processing as in:

r = raster(filename, band=1)
s = r > 21 & r < 25
s[!s] = NA

#or
s = reclass(r, c(-Inf, 11, NA, 22, 24, 1, 25, Inf, NA))
# 1/NA result

r = raster(filename, band=2)
s2 = reclass(r, c(-Inf, 11, NA, 22, 24, 1, 25, Inf, NA))

etc

s = s * s2 * ...

all of that should worn on a file of (practically) any size.
then

p = pointsToRaster(s)

Robert
On Wed, Jan 27, 2010 at 2:03 PM, Don MacQueen <macq at llnl.gov> wrote: