I´d like to create a netcdf file containing a mean and stddev for some variables for 12 months.
At this moment each geotiff (270MB) is either a mean or stddev of a month.
Now my problem is that I have no idea how to proceed from here, I have read plenty of documents about how to handle netcdf (How to extract, adapt and convert to other formats).
Is there a way to either use gdal or tools like ncdump to create a netcdf base file and then add each geotiff with extra metadata (variable, month and stddev or mean)? Or should the geotiff already have this metadata before using gdal to create a netcdf?
Here something similar is being done but I am not sure where in the python code the tiffs are imported and how each tiff is set to a certain date (My python skills are not up to par).
Best Answer
I figured out the answer some time ago but I hope this will help other people that are dipping their toes into the NetCDF file format.
I found that the easiest way to create a new NetCDF file containing several GeoTIFF files is using GDAL and then using NCO and CDO tools (Provided by unidata) to add the appropriate metadata.
First you convert the GeoTIFF´s to NetCDF using:
This creates a netCDF in NC4 format (which is the newest version at this time) with some basic metadata like coordinate system, pixel size etc.
Then I rename the variable information to what I want it to be (In my case SST) with the appropriately registered long and short name From the unidata convention page):
The first renames the variable Band1 to the wanted variable SST. The second adds the long name of the SST variable.
In my case I added time data to the new nc file using:
where the mean.nco file looks as follows:
This adds the third coordinate time where T=$d, which in my case was the january or 1. Then this time is set to the file using:
Finally all the files converted to NetCDF are joined together using:
This joins all files with the appropriate timestamp to one file. This can be with several parameters in one file.
Hope this helps someone.
Greetings, Frans