[Gdal-dev] issues merging 7 bands of Landsat scene into 1 image

Andrey Kiselev dron at ak4719.spb.edu
Fri Mar 16 09:09:28 EDT 2007


Maciej,

On Tue, Mar 13, 2007 at 10:37:17PM +0100, Maciej Sieczka wrote:
> So I tried GeoTIFF:
> 
> $ gdal_merge.py -of GTIFF -separate -o merge.tif nn*.tif
> 
> which went ok, BUT colortables of bands 2-6 are "Undefined" instead of
> "Gray":
> 
> $ gdalinfo merge.tif | grep ColorInterp
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 2 Block=254x32 Type=Byte, ColorInterp=Undefined
> Band 3 Block=254x32 Type=Byte, ColorInterp=Undefined
> Band 4 Block=254x32 Type=Byte, ColorInterp=Undefined
> Band 5 Block=254x32 Type=Byte, ColorInterp=Undefined
> Band 6 Block=254x32 Type=Byte, ColorInterp=Undefined
> Band 7 Block=254x32 Type=Byte, ColorInterp=Undefined
> 
> while the for each input image the ColorInterp is "Gray":
> 
> $ for i in `ls | grep nn.\.tif`; do gdalinfo $i | grep ColorInterp; done
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray
> Band 1 Block=254x32 Type=Byte, ColorInterp=Gray

And that is no problem. GDAL marks extra bands as being alpha-channels,
they will be read back well by the GDAL and other RS software.

> In that case I tried the -pct switch, but it makes gdal_merge.py crash:
> 
> $ gdal_merge.py -pct -of GTIFF -separate -o merge_pct.tif nn*.tif
> Traceback (most recent call last):
>   File "/usr/local/bin/gdal_merge.py", line 479, in ?
>     t_fh.GetRasterBand(1).SetRasterColorTable(file_infos[0].ct)
>   File "/usr/lib/python2.4/site-packages/gdal.py", line 892, in
> SetRasterColorTable
>     return _gdal.GDALSetRasterColorTable( self._o, ct._o )
> AttributeError: 'NoneType' object has no attribute '_o

That should be related to old style Python bindings your GDAL built
with. Try to rebuild with options '--without-python --with-ngpython'.
And you do not need color table here, really.

Best regards,
Andrey

-- 
Andrey V. Kiselev
ICQ# 26871517



More information about the Gdal-dev mailing list