[gdal-dev] NetCDF driver getting wrong values if compared to HDF5

Even Rouault even.rouault at spatialys.com
Wed Jul 31 08:19:29 PDT 2019


On mardi 30 juillet 2019 21:48:45 CEST Ivan Lucena wrote:
> Unsupported netCDF datatype (7), treat as Float32.​

Given that

#define NC_UBYTE        7       /**< unsigned 1 byte int */

and 

https://github.com/OSGeo/gdal/blob/master/gdal/frmts/netcdf/netcdfdataset.cpp#L357

it seems you would have a GDAL build against a netCDF build without NC4 support.

That said, even with that, I would have expected the ubyte to float32 conversion to be lossless.

but according to 
https://www.unidata.ucar.edu/software/netcdf/docs/group__variables.html#ga0ab808702d73b7f52be14b1e54473902
"""
The nc_get_vara() function will read a variable of any type, including user defined type.
For this function, the type of the data in memory must match the type of the variable - no data conversion is done.
"""

So you could get pretty much garbage.

Solution: build GDAL against a netCDF build that has NC4 support

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list