[R-sig-Geo] NAvalues on a raster stack

Els Ducheyne educheyne at avia-gis.be
Tue Nov 8 23:02:43 CET 2011


Dear Carsten and Robert
thanks for your help, I have now used reclass to do the job and this works perfectly
I will also check out subs and keeping the dataset as read
Els
On 8 Nov 2011, at 18:20, Robert J. Hijmans wrote:

> Els, 
> To add to what Carsten says: in that case you can use 'reclass' or 'subs'  or (at least in current versions) replacement:  ndvi.stack[ndvi.stack == -0.3] <- NA
> Robert
> 
> 
> On Tue, Nov 8, 2011 at 4:14 AM, Carsten Neumann <carstennh at aol.com> wrote:
>  Am 08.11.2011 09:18, schrieb Els Ducheyne:
> 
> Dear list
> I have been working with raster stack for a while. Until now I have not experienced any problems with NAvalues on stacks. However, yesterday I was stacking 6 layers in a stack. 4 of these seemed to contain background values only with a value of -0.3.
> I have tried to set the NAvalue on the stack as follows
> NAvalues(ndvi.stack)<-  -0.3
> 
> but when using summarise(ndvi.stack,na.rm=T) I still get the -0.3 values.
> The main problem is that I am calculating monthly means after this step as follows
> monthly.mean<- calc(ndvi.stack,fun=mean,na.rm=T) and that because of the fact that the NA value is not accepted i get wrong outputs.
> 
> is the NAvalue not accepted because the entire image is -0.3? or is there another reason?
> 
> i am using the Raster package version 1.9-5
> Thanks for any suggestions
> Best regards
> Els
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> Dear Els,
> 
> did you keep your dataset 'ndvi.stack' as read from disk? The function Navalues can only change values when reading your rasterStack object from disk. If you have your values in memory nothing will change applying your function.
> 
> Maybe this could help?
> 
> Best regards
> 
> Carsten
> 
> -- 
> 
> Carsten Neumann
> Telegrafenberg, A 17 01.13
> 14473 Potsdam
> -------------------------------------------------------
> Helmholtz Centre Potsdam
> GFZ German Research Centre for Geosciences
> Department 1 - Section 1.4 - Remote Sensing
> -------------------------------------------------------
> Tel.: +49 (0) 331 288 1766
> e-mail: carstenn at gfz-potsdam.de
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 



More information about the R-sig-Geo mailing list