Skip to content
Prev 20784 / 29559 Next

NAvalue() from raster not working?

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