Both seem to work fine in the R raster environment as, by loading and plotting them with
library(ncdf4) r.works <- raster::raster('MOD13Q1_2000-02-18.250m_16_days_NDVI.tif') r.dwork <- brick("spei01.nc") #this is a multilayer stack rasterVis::levelplot(r.works) rasterVis::levelplot(r.dwork[]) #plot just the first layer
I obtain clear graphs, respectively attached. However, if I use the ZonalPipe function to do fast zonal statistics within a grid, I obtain a lot of NA values for the latter (not shown/plotted here for neatness), even though both rasters cover 100% of the grid of interest. I obviously set both rasters' crs equal to the grid's one before doing zonal stats. I thus investigated both objects and they seem to differ
> r.works class : RasterLayer dimensions : 5000, 10444, 52220000 (nrow, ncol, ncell) resolution : 0.01, 0.01 (x, y) extent : -26.10815, 78.33185, -10, 40 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 data source : /Users/hannesmueller/Documents/NDVI Data/MOD13Q1_2000-02-18.250m_16_days_NDVI.tif names : MOD13Q1_2000.02.18.250m_16_days_NDVI values : -32768, 32767 (min, max) > r.dwork[] class : RasterLayer band : 1 (of 1380 bands) dimensions : 360, 720, 259200 (nrow, ncol, ncell) resolution : 0.5, 0.5 (x, y) extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 data source : /Users/hannesmueller/Dropbox/Locus Project Augustin Lavinia Bruno/gis data/spei/spei01.nc names : X1901.01.16 z-value : 1901-01-16 zvar : spei
band element of the second layer, whose meaning I do not understand. Finally, I exported them with
writeRaster(r.works, "rworks", format = "GTiff") writeRaster(r.dwork, "rdwork", format = "GTiff")
and the former opens perfectly in a GIS software, whereas the latter does not. That makes me very suspicious about the second raster, which was obtained with the .nc file. Am I importing it into R wrongly and/or missing any step when using zonal statistics/exporting it as geotiffs?