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):
gdal_translate -of VRT -b 1 netcdf:inputfile.nc:variable_name outputfile.vrt
2. Converting the layers
Batch convert VRTs into GTiff format always with gdal_translate, if you really need it. Example:
gdal_translate -ot Int32 inputfile.vrt outputfile.tif
3. Batch summing the layers
Is there a tool than batch sums up rasters within a folder?
Use gdal_calc.py. Example:
gdal_calc.py -A input1.tif -B input2.tif --outfile=result.tif --calc="A+B"
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.
Following on Vince's comment: you can remap your species to IDs that are powers of 2, as below, represented as integers and binary.
Species 1 --> 1 --> 00000001
Species 2 --> 2 --> 00000010
Species 3 --> 4 --> 00000100
You can see that each species is identified by a 1 in a unique slot in the bit sequence. So for each species, you'd have a raster with cells of either zero (no presence) or, say, 4 (species 3 is present). In a 32-bit integer, you have 32 of these slots.
When you add these layers together, you get a sum for each pixel that indicates which species are present.
Raster 1 --> 000000001
Raster 2 --> 000000010
Raster 3 --> 000000100
---------
Output --> 000000111 --> 6
In this instance, the value 6 tells you that species 1, 2 and 3 are present.
You can also use other operators such as bitwise AND not NOT to see cells where two or more specific species are present, or cells where certain species are not present together.
If you process your rasters this way, you can add them incrementally using a scriptable raster calculator like gdal_calc.py, adding each raster to the the sum of all previous rasters (though you'd probably have to turn all your rasters into VRTs first so that they have equal extents, etc.)
In QGIS you'll just add them all to the summation in the raster calculator.
Edit, based on the answer to Jens' comment and more info:
I'm answering the wrong question above. If you want only to sum the number of species in a cell and each cell-with-a-species is 1, you just add all the rasters together. To convert the NaN cells to zero, you can use the numpy function nan_to_num, which converts NaNs to zeroes. So you add like this:
nan_to_num("raster1@1") + nan_to_num("raster2@1")
Best Answer
Firstly, you can use gdal_calc.py to change all -9999 to 0 and set the NoData value to 0.
For instance:
Then, you can ignore NoData value using gdal_translate with the -a_nodata option followed by none.
Example: