I have several ncdf files in a folder. I would like to stack them individually in a loop and print their information in R.
I have the following code:
library(raster)
library(ncdf4)
c <- list.files(pattern="nc")
for (i in 1:length(c)){
ff <- stack(c[i])
print(ff[i])
}
by typing ff[1] in the command line, I expected to get that:
class : RasterStack
dimensions : 444, 922, 409368, 10 (nrow, ncol, ncell, nlayers)
resolution : 0.0625, 0.0625 (x, y)
extent : 235.375, 293, 25.125, 52.875 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
names : X1, X2, X3, X4, X5, X6, X7, X8, X9, X10
but I get the following:
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
[1,] NA NA NA NA NA NA NA NA NA NA
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
[1,] NA NA NA NA NA NA NA NA NA NA
I do not see where is my error. Thanks for any help.