[gdal-dev] netCDF signed nodata value

Kyle Shannon kyle at pobox.com
Tue Oct 27 08:54:56 PDT 2015


Simon,

On Mon, Oct 26, 2015 at 5:04 PM, Simon Lyngby Kokkendorff
<silyko at gmail.com> wrote:
> Hello list,
>
>    Just observed a puzzling behaviour of the netCDF driver. When creating a
> netCDF dataset of Byte type, the netCDF driver seems to interpret the nodata
> value as a signed byte.
>  For example a nodata value assigned with -a_nodata 200, will become -56. Of
> course one can work around this by simply casting the nodata value (as e.g.
> returned by band.GetNoDataValue()) to an unsigned byte.

It appears the driver has a sort of data type mis-match with no data
and the band type.  A work around, if available, is to set FORMAT=NC4
as a creation option.  I am not sure if it is in gdal or the netcdf
library at this point.

>
> A simple example:
>
>>gdalinfo --version
> GDAL 1.11.2, released 2015/02/10
>>gdal_translate -of netCDF -a_nodata 200 something.tif something.nc
>>gdalinfo something.nc
> Driver: netCDF/Network Common Data Format
> Files: something.nc
> Size is 10, 10
> Coordinate System is `'
> Origin = (0.000000000000000,10.000000000000000)
> Pixel Size = (1.000000000000000,-1.000000000000000)
> Metadata:
>   Band1#_FillValue=-56
>   Band1#_Unsigned=true
>   Band1#long_name=GDAL Band Number 1
>   Band1#valid_range={0,255}
>   lat#long_name=latitude
>   lat#standard_name=latitude
>   lat#units=degrees_north
>   lon#long_name=longitude
>   lon#standard_name=longitude
>   lon#units=degrees_east
>   NC_GLOBAL#Conventions=CF-1.5
>   NC_GLOBAL#GDAL=GDAL 1.11.2, released 2015/02/10
>   NC_GLOBAL#history=Mon Oct 26 23:58:09 2015: GDAL CreateCopy( something.nc,
> ... )
> Corner Coordinates:
> Upper Left  (   0.0000000,  10.0000000)
> Lower Left  (   0.0000000,   0.0000000)
> Upper Right (  10.0000000,  10.0000000)
> Lower Right (  10.0000000,   0.0000000)
> Center      (   5.0000000,   5.0000000)
> Band 1 Block=10x1 Type=Byte, ColorInterp=Undefined
>   NoData Value=-56
>   Metadata:
>     _FillValue=-56
>     _Unsigned=true
>     long_name=GDAL Band Number 1
>     NETCDF_VARNAME=Band1
>     valid_range={0,255}
>
> Cheers,
> Simon Kokkendorff, DMI
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



-- 
Kyle


More information about the gdal-dev mailing list