Ticket #2285 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

pct2rgb does not work on Linux 64 bits systems

Reported by: jcrepetto Owned by: warmerdam
Priority: high Milestone: 1.5.3
Component: PythonBindings Version: 1.5.0
Severity: normal Keywords: numpy
Cc: hobu

Description

I have downloaded a map of Corsica at < http://www.ign.fr/telechargement/MPro/produit/SCANS/SCAN1000_Corse_L2E.zip> .

Now, I want to convert it to ECW format with gdal_translate. As it uses a palette, I first need to convert it to RGB.

$ pct2rgb.py COR_0000.TIF COR_0000_64K.TIF
0Traceback (most recent call last):
  File "/usr/bin/pct2rgb.py", line 162, in ?
    tif_ds.GetRasterBand(iBand+1).WriteArray(dst_data,0,iY)
  File "/usr/lib64/python2.4/site-packages/gdal.py", line 796, in WriteArray

  File "usr/lib64/python2.4/site-packages/osgeo/gdal_array.py", line 157, in BandWriteArray
ValueError: array does not have corresponding GDAL data type

The same command is working on Linux 32 bits systems.

Change History

Changed 5 years ago by jcrepetto

  • version changed from unspecified to 1.5.0

Changed 5 years ago by warmerdam

  • cc hobu added
  • keywords numpy added
  • status changed from new to assigned
  • component changed from default to PythonBindings

I have confirmed this occurs locally on my 64bit system with GDAL trunk.

warmerda@gdal64[9]% pct2rgb.py public_html/frank.gif out.tif --debug off
0Traceback (most recent call last):
  File "/home/warmerda/gdal/swig/python/scripts/pct2rgb.py", line 162, in <module>
    tif_ds.GetRasterBand(iBand+1).WriteArray(dst_data,0,iY)
  File "/home/warmerda/gdal/swig/python/build/lib.linux-x86_64-2.5/osgeo/gdal.py", line 832, in WriteArray
    return gdalnumeric.BandWriteArray( self, array, xoff, yoff )
  File "/home/warmerda/gdal/swig/python/build/lib.linux-x86_64-2.5/osgeo/gdal_array.py", line 157, in BandWriteArray
    raise ValueError, "array does not have corresponding GDAL data type"
ValueError: array does not have corresponding GDAL data type

Changed 5 years ago by warmerdam

  • priority changed from normal to high

Ok, I took a new crack at this and discovered that pct2rgb.py was passing numpy.int64 arrays into BandWriteArray?() and there is no direct mapping from this type to anything that GDAL supports. I modified the method to cast to Float64 in this case in trunk (r15480).

If this does not cause any other apparent problems, then I'll port the change back into 1.5 branch before the 1.5 release.

Changed 5 years ago by warmerdam

  • status changed from assigned to closed
  • resolution set to fixed

I have merged this change back into 1.5 branch as well (r15500).

Note: See TracTickets for help on using tickets.