[gdal-dev] Reading signed 8-bit Erdas Imagine .img (HFA driver)
Jason Roberts
jason.roberts at duke.edu
Tue Sep 1 23:29:44 EDT 2009
Frank,
Thanks! Indeed, PIXELTYPE is set to SIGNEDBYTE:
>>> band.GetMetadata('IMAGE_STRUCTURE')
{'PIXELTYPE': 'SIGNEDBYTE', 'COMPRESSION': 'RLC'}
I am sorry I missed that in the RFC. It is obvious now. I need to read up on
GDAL's metadata infrastructure.
Do you have any advice on deducing the correct nodata value, given that
band.GetNoDataValue() is returning 0? It seems for IMGs as though the nodata
value is always set to the minimum possible value for the datatype in
question, but I do not know if this is part of the IMG spec, is an ArcGIS
behavior (since I'm generating IMGs with ArcGIS), or if GDAL is responsible.
If this rule is guaranteed, I am comfortable hard coding -128 if I detect
that it is a signed 8-bit image.
It does seem as though 32-bit signed IMGs, like ArcInfo Binary Grids, always
use -2147483647 as the nodata value, rather than -2147483648. As above, I do
not know if this is due to the IMG spec, ArcGIS behavior, or GDAL. If you
know the reason for this, I'd love to hear it. (But don't let me waste your
time on trivia...)
Thanks again for your help,
Jason
-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Tuesday, September 01, 2009 11:05 PM
To: Jason Roberts
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Reading signed 8-bit Erdas Imagine .img (HFA driver)
Jason Roberts wrote:
>>>> band.GetMetadata()
> {'LAYER_TYPE': 'athematic', 'STATISTICS_MAXIMUM': '126',
> 'STATISTICS_MINIMUM': '-127', 'STATISTICS_STDDEV': '109.55249883047',
> 'STATISTICS_HISTOBINVALUES': '3|3|', 'STATISTICS_MEAN':
'-0.33333333333333',
> 'STATISTICS_MODE': '6.2891288834462e-247', 'STATISTICS_MEDIAN':
> '6.2896744699688e-247'}
>
> As you can see, there is no PIXELTYPE metadata entry for the band. Is that
> entry only created when GDAL creates the file? In any case, it is possible
> to detect that the true values fit in the int8 range, not the uint8 range:
Jason,
The PIXELTYPE metadata is in the IMAGE_STRUCTURE domain, so you need to
fetch it like:
md = band.GetMetadata('IMAGE_STRUCTURE')
Best regards,
--
---------------------------------------+------------------------------------
--
I set the clouds in motion - turn up | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the gdal-dev
mailing list