[gdal-dev] netCDF signed nodata value
Simon Lyngby Kokkendorff
silyko at gmail.com
Mon Oct 26 16:04:28 PDT 2015
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.
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20151027/b18bbbe5/attachment.html>
More information about the gdal-dev
mailing list