[R-sig-Geo] stack problem

Amen Alyaari amen.alyaari at bordeaux.inra.fr
Tue Mar 19 10:53:59 CET 2013


Hello All,

I have several rasters that I want to do some calculations ,basically 
calculating the moving average.

             dir2 <- list.files("D:\\2010+2011", "*.bin", full.names = 
TRUE)
            saf=stack(dir2)

code

           movi <-  overlay(stack(saf),fun=function(x) movingFun(x, 
fun=mean, n=3,  na.rm=TRUE))
              Error in .overlayList(x, fun = fun, filename = filename, 
...) :
          cannot use this formula, probably because it is not vectorized
  I then checked the data but found that all values were returned as NA 
and this may explain why I am getting the error.

when the files are stacked ,all in all are NAs
         saf
        class       : RasterStack
        dimensions  : 720, 1440, 1036800, 601  (nrow, ncol, ncell, nlayers)
        resolution  : 0.25, 0.25  (x, y)
        extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
       coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 
+no_defs
      names       : Vol_025_H//00_1_wgs84, Vol_025_H//00_1_wgs84, 
Vol_025_H//00_1_wgs84,    Vol_025_H//00_1_wgs84, Vol_025_H//00_1_wgs84, 
Vol_025_H//00_1_wgs84, , ...
     min values  :                    NA,                    
NA,                    NA,                       NA,                    
NA,                    NA,                    NA,                     
NA,                    NA,                    NA,                    
NA,                    NA,                    NA,                    
NA,                    NA, ...
     max values  :                    NA,                    
NA,                    NA,                    NA,                    
NA,                    NA,                    NA,                    
NA,                    NA,                    NA,                    
NA,                       NA,                    NA,                    
NA,                    NA, ...


something is wrong because there is no NAs in my files. All  values are 
up to 9999. I wonder why this is happening, I checked the files 
separately(summary) and everything was right!as you can see bellow:

               summary(saf)
              ol_025_H14_2011092000_1_wgs84 
Vol_025_H14_2011092100_1_wgs84   Vol_025_H14_2011092200_1_wgs84 
Vol_025_H14_2011092300_1_wgs84 Vol_025_H14_2011092400_1_wgs84
       Min.                           0.00000                      
0.0000000                            0.0000000                      
0.0000000                      0.0000000
      1st Qu.                        0.31883                      
0.3163167                      0.3146436                      
0.3113111                      0.3064551
      Median                      9999.00000                   
9999.0000000                   9999.0000000                   
9999.0000000                   9999.0000000
      3rd Qu.                     9999.00000                   
9999.0000000                   9999.0000000                   
9999.0000000                   9999.0000000
       Max.                        9999.00000                   
9999.0000000                   9999.0000000                   
9999.0000000                   9999.0000000
      NA's                           0.00000                      
0.0000000                        0.0000000                      0.00000

   I checked with only two files, but I got the same error:

               class       : RasterStack
         dimensions  : 720, 1440, 1036800, 2  (nrow, ncol, ncell, nlayers)
         resolution  : 0.25, 0.25  (x, y)
         extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
         coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 
+no_defs
        names       : Vol_025_H14_2010011400_1_wgs84, 
Vol_025_H14_2010011500_1_wgs84
         min values  :                             
NA,                             NA
         max values  :                             
NA,                             NA

 > summary(saf)
               Vol_025_H14_2010011400_1_wgs84 
Vol_025_H14_2010011500_1_wgs84
         Min.                             0.000                          
0.000
         1st Qu.                          0.159                          
0.159
         Median                        9999.000                       
9999.000
         3rd Qu.                       9999.000                       
9999.000
         Max.                          9999.000                       
9999.000
        NA's                             0.000                          
0.000
I am grateful to anyhelp

download the two files I checked here: 
https://echange-fichiers.inra.fr/get?k=bWqfIVMDR5UgQnff6eU

-- 
Amen Alyaari, UPMC
PhD student
Unit of Functional Ecology&  Environmental Physics [EPHYSE]
National Institute of Agricultural Research [INRA].
71, Avenue Edouard Bourlaux
33140 Villenave d'Ornon
Téléphone : +33(0) 5 57 12 24 27
Fax : +33 (0)5 57 12 24 20
FRANCE



More information about the R-sig-Geo mailing list