[gdal-dev] Bug in of GDALRead.cs

markus.u.mueller markus.u.mueller at zoho.com
Wed May 8 15:07:34 PDT 2013


Dear listers,

I  think I found a bug in GDALReadDirect.cs (part of FWTools). Is this the right place to record it? I will describe the problem anyway and would be willing to move it to another place if more appropriate.


I want to read Arc/Info Binary Grids and convert them to other image formats using the C#-bindings of GDAL. I installed FWTools 2.4.7 and the current binaries (MSVC2010 (Win64) -stable) from http://vbkto.dyndns.org/sdk/. Then I started testing the example C#-programs that are part of FWTools, especially  GDALReadDirect.cs. When I use the demo dataset utm.tif, this all works fine.
I then converted utm.tif to the Arc/Info Binary Grid format using ArcMap 10 (Conversion Tools - To Raster - Raster to other Format). When I try to use  GDALReadDirect.cs I get the following error messages:
Using driver Arc/Info Binary Grid Band 1 : DataType: GDT_Int16 Size (512,512) PaletteInterp: GCI_Undefined OverView 0 : DataType: GDT_Int16 Size (256,256) PaletteInterp: GCI_GrayIndex OverView 1 : DataType: GDT_Int16 Size (128,128) PaletteInterp: GCI_GrayIndex The number of the raster bands is not enough to run this sample
GDALReadDirect.cs obviously has an erroneous method named SaveBitMapDirect, that first checks on the available Color interpretation and then on the number of bands. After the file is converted to Arc/Info binary Grid format, the information about the Color interpretation is lost, so only then the program checks on the number of available bands and returns an error message. SaveBitMapDirect works for the described case if Line 157 is edited:
if (redBand.GetRasterColorInterpretation() == ColorInterp.GCI_GrayIndex || redBand.GetRasterColorInterpretation() == ColorInterp.GCI_Undefined)
This is not a general fix, only for the immediate problem.




Cheers,


Markus










-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130508/b35be70a/attachment.html>


More information about the gdal-dev mailing list