Skip to content
Prev 11801 / 29559 Next

raster: creating a layer of NA

Based on the example by Pierre:

logo <- raster(system.file("external/rlogo.grd", package="raster"))
# Use this rastre to create a new, void Raster object
r <- raster(logo)
class       : RasterLayer
dimensions  : 77, 101, 7777  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 101, 0, 77  (xmin, xmax, ymin, ymax)
projection  : +proj=merc +ellps=WGS84
values      : none

# Set to NA
r[] <- NA
class       : RasterLayer
dimensions  : 77, 101, 7777  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0, 101, 0, 77  (xmin, xmax, ymin, ymax)
projection  : +proj=merc +ellps=WGS84
values      : in memory
min value   : NA
max value   : NA

So this should work for your raster:

D10N2009[] <- NA


Cheers, Lyndon
On Wed, May 25, 2011 at 2:32 AM, Roman Lu?trik <roman.lustrik at gmail.com> wrote: