[R-sig-Geo] Changing the NA value

Brian Oney zenlines at gmail.com
Thu Aug 11 09:16:50 CEST 2011


Hi All,
I guess I have a few questions:

there are ways to change NA values, such as:

http://r-sig-geo.2731867.n2.nabble.com/NA-raster-replace-td6348031.html

When running a few tests on the different methods that do the same 
thing, I get:
# rast is a raster with appr. 1.5e6 cells
# when I look at str(rast) I see that I can:

 > system.time(rast at file@nodatavalue <- -9995)
    user  system elapsed
       0       0       0
# Or this
 > system.time(rast[is.na(rast)] <- -9996)
    user  system elapsed
    6.55    0.53    7.13
# And finally:
 > system.time(rast <- calc(rast,function(x)ifelse(is.na(x),-9997,x)))
    user  system elapsed
   67.61    0.08   67.83

Will the 1st referencing method listed also work in the future? Is this 
recommended?
How can I change the default NA value i.e. for a session?
I haven't read the do's and don'ts of (R) programming. Where can I do that?

Cheers,
Brian



More information about the R-sig-Geo mailing list