2

I'm trying to convert a GeoTIFF with CRS EPSG:2056 to NetCDF. Similar questions suggest to do:

gdal_translate -of netcdf input.tif output.nc

Unfortunately this doesn't encode the CRS information in the resulting NetCDF. By googling I've found and tested also the following:

gdalbuildvrt output.vrt input.tif

gdal_translate -of netcdf output.vrt output.nc

This returns me the following errors:

ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid .at (e:\buildsystem\src\gdal-3-4-vc15x64\gdal\frmts\netcdf\netcdfdataset.cpp,netCDFDataset::AddProjectionVars,5368)

ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid . at (e:\buildsystem\src\gdal-3-4-vc15x64\gdal\frmts\netcdf\netcdfdataset.cpp,netCDFDataset::AddProjectionVars,5372)

I've tried with different GeoTIFFs and with a couple of GDAL version (3.3 and 3.4) on both Linux and Windows.

Any hint?

1 Answer 1

1

I believe that EPSG:2056 is not valid in NetCDF but I am not sure because there are several conventions. I checked this one http://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#appendix-grid-mappings.

I am not sure if this test confirms my assumption or not.

Assign EPSG:2056 and get a failure

gdal_translate -a_srs EPSG:2056 -of netcdf test.tif output1.nc
Input file size is 2000, 2000
0...10ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid .
at (E:\buildsystem\src\gdal-vc17x64\frmts\netcdf\netcdfdataset.cpp,netCDFDataset::AddProjectionVars,5323)

ERROR 1: netcdf error #-50 : NetCDF: Action prohibited on NC_GLOBAL varid .
at (E:\buildsystem\src\gdal-vc17x64\frmts\netcdf\netcdfdataset.cpp,netCDFDataset::AddProjectionVars,5327)

Assign UTM Zone 33 and conversion does not give errors

gdal_translate -a_srs EPSG:32633 -of netcdf test.tif output2.nc

I suggest to warp the image into some supported CRS with gdalwarp.

gdalwarp -of netcdf -t_srs EPSG:32633 input.tif output.nc
1
  • Many thanks for your inputs! I'm not really expert of the NetCDF conventions, anyway I've been able to get a NetCDF file in EPSG:2056 with ArcMap ... but that is ArcMap and I'd prefer using open source tools!
    – p1d1d1
    Mar 22, 2022 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.