[R-sig-Geo] raster: creating a layer of NA

Agustin Lobo alobolistas at gmail.com
Wed May 25 08:05:13 CEST 2011


HI!

I must create a layer with all missing values. I try:
> show(D10N2009)
class       : RasterBrick
dimensions  : 393, 606, 35  (nrow, ncol, nlayers)
resolution  : 0.008928571, 0.008928571  (x, y)
extent      : -2.004464, 3.40625, 40.49554, 44.00446  (xmin, xmax, ymin, ymax)
projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
values      : /media/Iomega_HDD/FLUXPYR/VGTFLUXPYR1/D10/FLXP_NDD10_2009.vrt
min values  : 0 0 0 0 0 0 0 0 0 0 ...
max values  : 255 255 255 255 255 255 255 255 255 255 ...

> delme = D10N2009[[1]]*0
> show(delme)
class       : RasterLayer
dimensions  : 393, 606, 238158  (nrow, ncol, ncell)
resolution  : 0.008928571, 0.008928571  (x, y)
extent      : -2.004464, 3.40625, 40.49554, 44.00446  (xmin, xmax, ymin, ymax)
projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
values      : in memory
min value   : 0
max value   : 0

But
> delme = D10N2009[[1]]*NA
Error in D10N2009[[1]] * NA : non-numeric argument to binary operator

I also try
> NAvalue(delme) <- 0
but no trace of the NAs:
> show(delme)
class       : RasterLayer
dimensions  : 393, 606, 238158  (nrow, ncol, ncell)
resolution  : 0.008928571, 0.008928571  (x, y)
extent      : -2.004464, 3.40625, 40.49554, 44.00446  (xmin, xmax, ymin, ymax)
projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
values      : in memory
min value   : 0
max value   : 0

By now I write with NAflag=0 and read back, but there must be a
cleaner way of generating a layer with all NA values
(it's a missing layer for a particular time)

Thanks!

Agus



More information about the R-sig-Geo mailing list