I am trying to convert GeoTIFF (.tif) files to NetCDF (.nc) format. These files are in the Swiss coordinate system (EPSG:2056 - Swiss CH1903+ / LV95) but unfortunately, when using standard GDAL commands, the conversion fails. Often a netcdf file is created but it is missing its spatial reference.
When using the GDAL command (or similar alternatives):
gdal_translate -if GTiff -of NetCDF -a_srs 2056.prj <input_file> ,output_file>
The following error messages are received:
ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid .
at (netcdfdataset.cpp,AddProjectionVars,5368)
ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid .
at (netcdfdataset.cpp,AddProjectionVars,5372)
I have tested many different files, different operating systems and using programs such as ArcGIS and QGIS (which ultimately use Gdal). SwissTopo indicate that the EPSG should be compatible.
Incidentally this problem does not occur with other coordinate systems such as standard lat/lon (WGS 84) or UTM. The conversion works perfectly fine.