For the first time, I am using NetCDF data files containing daily data about soil moisture at a global level.
I want to be able to obtain monthly mean value of soil moisture for each grid cell.
There is one NetCDF file for each day, and each file contains four bands. I only need the first band which contains the data I want.
Using QGIS 1.8, I encounter the following problems:
1. Loading the rasters
When I want to load the 31 rasters related to January (example), I can select the 31 files, but then, I have to select the band I am interested in for each layer, one by one. Is there a way to load all of them, but automatically select the band I want?
2. Converting the layers
The data comes in a floating number format. I detected some issues when it comes to sum values. However, when I convert the layer to a .tiff raster, it seems to transform the value into an integer. This is what I want, but GDAL doesn't want to batch convert all the files into .tiff, either because of the file names of because of the multiband issue. Is there a way to batch convert NetCDF files into .tiff?
3. Batch summing the layers
Finally, even if I have the layer in .tiff format, I wonder if there is an easier way to sum all the values than by using RasterCalculator. Is there a tool than batch sums up rasters within a folder?
Also, I noticed that I cannot use RasterCalculator directly on the NetCDF layers because of the file names. If the solution is on this trail, is there a way to batch change the name of a layer within a NetCDF file?
Best Answer
1. Loading the raster
Batch convert with gdal_translate the daily soil moisture NetCDF files into GDAL VRT format specifying the band you want to use. Example (band 1):
2. Converting the layers
Batch convert VRTs into GTiff format always with gdal_translate, if you really need it. Example:
3. Batch summing the layers
Is there a tool than batch sums up rasters within a folder?
Use gdal_calc.py. Example:
Is there a way to batch change the name of a layer within a NetCDF file?
If you use the VRT format, you can name the layers as you want.