[gdal-dev] GDALGetMaskFlags() bug with GTOPO30 data

Even Rouault even.rouault at mines-paris.org
Thu May 31 12:29:14 PDT 2012


Le jeudi 31 mai 2012 20:41:14, Craig Bruce a écrit :
> I have run into a bug using GDALGetMaskFlags() with GTOPO30 data with
> the GDAL 1.9.0 C API.  The test data includes a NoData value:
> 
> [dev:~] gdalinfo /cw/testdata/gtopo30/w180s60.dem
> Driver: EHdr/ESRI .hdr Labelled
> ...
> Band 1 Block=7200x1 Type=Int16, ColorInterp=Undefined
>   NoData Value=-9999
> 
> When I call GDALGetMaskFlags(), I get back 0x01 which corresponds to
> GMF_ALL_VALID, meaning that the image is fully opaque.  I was hoping to
> discard the mask band in such a case as an optimization to avoid reading
> mask samples.  However, it appears that the GDALGetMaskFlags() is returing
> GMF_ALL_VALID by mistake and should be returning GMF_NODATA (0x08) instead.
> If I use the mask returned from GDALGetMaskBand(), it gives me the proper,
> variable mask values, so the bug is in falsely reporting the type of the
> mask band.

I cannot replicate, at least with the following Python script, that displays 8 
as expected :

from osgeo import gdal
ds = gdal.GetDriverByName('EHdr').Create('test.bil', 1, 1)
ds.GetRasterBand(1).SetNoDataValue(-9999)
ds = None
ds = gdal.Open('test.bil')
print(ds.GetRasterBand(1).GetMaskFlags())

I somehow suspect you didn't write exactly what you did and/or your 
expectations are wrong because there's no other way of getting the mask flags. 
If you do GetMaskBand().GetMaskFlags(), then it will return 0x1, since the 
mask band itself has no mask.


More information about the gdal-dev mailing list