[gdal-dev] Negative NoData Value with Signed Byte Raster

Jason Greenlaw - NOAA Affiliate jason.greenlaw at noaa.gov
Wed Apr 6 11:38:36 PDT 2016


Hello,

I've run into a snag trying to assign a negative NoData value to a Signed
Byte raster.

Example:

gdal_translate -a_nodata -128 -ot Byte -co PIXELTYPE=SIGNEDBYTE
signed8test.tif signed8testnew.tif


produces this error:

for band 1, nodata value has been clamped to 0, the original value being
out of range.


Whereas gdal_calc.py does not throw the same error and assigns the value:


gdal_calc.py -A signed16test.tif --outfile=signed8test.tif
--NoDataValue=-128 --co=COMPRESS=LZW --co=TILED=yes --type=Byte
--co=PIXELTYPE=SIGNEDBYTE --calc="A+(A<0)*256"
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100 - Done


It seems gdal_calc.py does not enforce any restriction on NoData, as it
even allows values outside the valid range (e.g. -999).

There also appears to be some confusion in applications (e.g. ArcGIS) as to
whether a NoData value between -127 to -1 should be expressed in that range
explicitly or in the actual pixel value range of 128 - 255.  I could not
find any documentation online describing the standard, so I suspect it may
be up to each application to interpret it according to preference.

So, I suppose my questions are:

1) Are negative NoData values (-127 to -1) for the SIGNEDBYTE type supposed
to be supported by GDAL?
2) Is there a convention which states that they must be expressed in the
range -127 to -1 or 128 to 255?

Regards,
Jason Greenlaw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160406/72580128/attachment.html>


More information about the gdal-dev mailing list