[R-sig-Geo] NAvalue() from raster not working?

Agustin Lobo alobolistas at gmail.com
Wed Apr 9 15:27:02 CEST 2014


I have raster layers with may nodata values (-10000)
I set them as NAvalues but nothing seems to change:

r <- raster(matrix(runif(100),nrow=10))
r[seq(10,100,by=10)]<- -10000
cellStats(r,mean)
[1] -999.521

NAvalue(r) <- -10000
cellStats(r,mean)
[1] -999.521

Instead:
r[r==-10000] <- NA
cellStats(r,mean)
[1] 0.5322636

is this the intentional behaviour?
what is NAvalues() for in that case?
Thanks
Agus



More information about the R-sig-Geo mailing list