Opened 15 years ago

Closed 15 years ago

#3152 closed defect (fixed)

HFA doesn't support reading COMPRESSED + SIGNEDBYTE

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.6.3
Component: GDAL_Raster Version: 1.6.2
Severity: normal Keywords:
Cc: jjr8

Description

The following snippet :

import gdal
driver = gdal.GetDriverByName('HFA')
dataset = driver.Create(r'test2_int8d.img', 5, 3, 3, gdal.GDT_Byte, ['COMPRESSED=YES', 'PIXELTYPE=SIGNEDBYTE'])
band = dataset.GetRasterBand(1)
band.Fill(0)
band.FlushCache()
print band.Checksum()

raises the following error :

ERROR 1: Attempt to uncompress an unsupported pixel data type.
ERROR 1: IReadBlock failed at X offset 0, Y offset 0
ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0
ERROR 3: Checksum value couldn't be computed due to I/O read error.

Change History (2)

comment:1 by jjr8, 15 years ago

Milestone: 1.6.3
Version: unspecified1.6.2

This repros in 1.6.2. Changing the milestone to 1.6.3 so it comes up on your radar. Please adjust appropriately.

The original scenario was that I wanted to calculate statistics after writing a band. It seemed like a good idea to flush the band before calculating statistics:

>>> band.WriteArray(b)
0
>>> band.FlushCache()
>>> band.GetStatistics(False, True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\Lib\site-packages\GeoEco\AssimilatedModules\osgeo\gdal.py", line 725, in GetStatistics
    return _gdal.Band_GetStatistics(*args)
RuntimeError: Failed to compute statistics, no valid pixels found in sampling

If it is possible to successfully calculate statistics for a large raster (8192x4096) without calling FlushCache first, then I am happy to omit the FlushCache and this becomes a lower priority issue for me. Please advise me on the possibility of that. If it is not possible, then I would appreciate if this were fixed relatively soon. Thanks for your consideration.

Note that the statistics values for SIGNEDBYTE datasets were not correct until #3151 was fixed.

comment:2 by Even Rouault, 15 years ago

Resolution: fixed
Status: newclosed
Summary: HFA + COMPRESSED + SIGNEDBYTE + FlushCache()+ Read = FAILHFA doesn't support reading COMPRESSED + SIGNEDBYTE

Fixed in trunk (r17690) and branches/1.6 (r17691).

For the record, you never need to call FlushCache() explicitely. The HFA driver was just missing reading back compressed s8 files. Without FlushCache() the whole data for a small file was fitting into the GDAL block cache. FlushCache() flushed it to disk and wiped the cache. Then GetStatistics() or Checksum() need to read it from the disk, hence the error.

8192 * 4096 * 1 band = 33.5 MB < 40 MB, the default size of the block cache, so you probably wouldn't need the fix. If the raster is larger, GDAL will necessarily need to flush blocks to disk and read them back later

Note: See TracTickets for help on using tickets.