[gdal-dev] Problem with GetNoDataValue function

Even Rouault even.rouault at mines-paris.org
Fri Aug 6 18:06:02 EDT 2010


Le vendredi 06 août 2010 23:41:37, Greg Coats a écrit :
> I agree that unsigned byte does not support -128. Signed byte does support
> -127. 

Yes

> Signed byte does not could support -128.

No, the validty range of a signed byte is [-128,127]. 

> I note that
> http://www.gdal.org/gdal_translate.html shows that gdal_translate supports
> 11 data types
> Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/CInt16/CInt32/CFloat32/CFlo
> at64, and "Byte" is included, but I think this "Byte" refers to unsigned
> byte. I do not see any indication that gdal_translate supports signed
> byte. 

It's a bit more complex than that...

GDAL can actually deal with signed byte datatype in a limited way. A few 
drivers like GTiff, HFA, EHDR or ERS can return a band of type Byte with 
PIXELTYPE=SIGNEDBYTE  in the IMAGE_STRUCTURE metadata domain. This means that 
the data returned by ReadBlock()/RasterIO() must be interpretated as a signed 
byte instead of the default unsigned byte. See 
http://gdal.org/gdal_datamodel.html.

GTiff and HFA drivers also support a SIGNEDBYTE creation option to mark a 
dataset as being of type signed byte instead of unsigned byte.

I'd note that there have been fixes a few month ago in GDAL statistic 
computations to take into account the SIGNEDBYTE case 
(http://trac.osgeo.org/gdal/ticket/3151 -> fixed after 1.6.2), but there are 
perhaps other areas where it isn't properly taken into account.

> 
> On Aug 6, 2010, at 12:23 PM, Even Rouault wrote:
> > Filippo,
> > 
> > What is the format of that raster file ? Can you share a link to the
> > dataset ? or the output of gdalinfo at the very least
> > 
> > I'd note that -128 can only be considered a valid value for a 8bit raster
> > if the metadata item PIXELTYPE at band level is set to SIGNEDBYTE
> > (IMAGE_STRUCTURE metadata domain).
> > 
> > Best regards,
> > 
> > Even
> > 
> > Le vendredi 06 août 2010 18:08:56, Filippo Corò a écrit :
> >> Hi List,
> >> 
> >> I have a problem with the function GetNoDataValue () of GDAL 1.6.2 ver.
> >> I use some raster where the nodatavalue is equal to -128 and the pixel
> >> depth is 8bit. Opening the raster with the following code (with pydev 
> >> end python 2.6):
> >> 
> >> # Get the bands and block sizes
> >> primoBand primoDs.GetRasterBand = (1)
> >> noval primoBand.GetNoDataValue = ()
> >> 
> >> Get noval = 0.0 and not -128 as I expected.
> >> Is there any option I can use to solve the problem?
> >> 
> >> Thanks in Advance
> >> 
> >> Greetings
> >> Filippo Corò
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list