I'm using gdal_retile to create ImagePyramid from a set of GeoTIFF images. I'm using following command:

gdal_retile.py -v -r bilinear -levels 8 -ps 2048 2048 -co "TILED=YES" -co "COMPRESS=JPEG" -targetDir F:/tiles --optfile F:/tileslist.txt

After couple of hours(source images are 320GB) I get following error message:

Traceback (most recent call last):
  File "C:\PROGRA~2\FWTOOL~1.7\bin\gdal_retile.py", line 940, in ?
  File "C:\PROGRA~2\FWTOOL~1.7\bin\gdal_retile.py", line 857, in main
    dsCreatedTileIndex = tileImage(minfo,ti)
  File "C:\PROGRA~2\FWTOOL~1.7\bin\gdal_retile.py", line 335, in tileImage
    createTile(minfo, offsetX, offsetY, width, height,tilename,OGRDS)
  File "C:\PROGRA~2\FWTOOL~1.7\bin\gdal_retile.py", line 467, in createTile
  File "C:\PROGRA~2\FWTOOL~1.7\bin\gdal_retile.py", line 246, in getDataSet
    s_band = sourceDS.GetRasterBand( bandNr )
  File "C:\PROGRA~2\FWTOOL~1.7\pymod\gdal.py", line 654, in GetRasterBand
    raise ValueError, 'Out of range band requested: %d' % i
ValueError: Out of range band requested: 2

I tried to retile separately images that execution stops on, but then I get no error message. Everything works well, so my guess that it's something wrong with the source image doesn't seem to be valid.

Does anyone have any other ideas of what could be wrong or how I should troubleshoot the problem?

1 Answer 1


Try running gdalinfo on the files that give you trouble, and the files that are ok, and looking at the number of bands. Quickly looking over the code, it looks like gdal_retile.py doesn't handle images with different numbers of bands.

If that's the case, you'll need to use gdal_translate to expand or repeat bands so all the files are the same depth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.