1

Does anybody have some insight to an error I am getting when I use gdal2tiles.py:

ERROR 6: PNG driver doesn't support 13 bands.  Must be 1 (grey),
2 (grey+alpha), 3 (rgb) or 4 (rgba) bands.

I am starting with my original file, "my-file.tif" going through the following workflow:

  1. my-file.tif => gdalwarp => newFile.tif
    • gdalwarp -co TILED=YES -co COMPRESS=DEFLATE -t_srs EPSG:3857 my-file.tif newImage.tif
  2. gdal2tiles.py newImage.tif out-dir/

Here is the info for the original TIF (incidentally, newImage.tif has the same bands listed):

$ gdalinfo my-file.tif
Driver: GTiff/GeoTIFF
Files: my-file.tif
Size is 10800, 10800
Coordinate System is:
GEOGCS["GRS 1980(IUGG, 1980)",
    DATUM["unknown",
        SPHEROID["GRS80",6378137,298.257222101],
        TOWGS84[0,0,0,0,0,0,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
Origin = (-122.000000000000000,49.000000000004398)
Pixel Size = (0.000092592592593,-0.000092592592593)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (-122.0000000,  49.0000000) (122d 0' 0.00"W, 49d 0' 0.00"N)
Lower Left  (-122.0000000,  48.0000000) (122d 0' 0.00"W, 48d 0' 0.00"N)
Upper Right (-121.0000000,  49.0000000) (121d 0' 0.00"W, 49d 0' 0.00"N)
Lower Right (-121.0000000,  48.0000000) (121d 0' 0.00"W, 48d 0' 0.00"N)
Center      (-121.5000000,  48.5000000) (121d30' 0.00"W, 48d30' 0.00"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Gray
  NoData Value=255
Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 5 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 6 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 7 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 8 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 9 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 10 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 11 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255
Band 12 Block=256x256 Type=Byte, ColorInterp=Undefined
  NoData Value=255

1 Answers1

5

You have 13 band imagery, but to make a PNG tile you need to restrict it to just the 3 RGB values. You can build a VRT "virtual file" that selects just the RGB bands from the source:

gdalbuildvrt -b [red] -b [green] -b [blue] newFile.vrt newFile.tif

and then try to run gdal2tiles newFile.vrt on that.

You could also skip the gdal_warp step by including the reprojection in the VRT generation:

gdalbuildvrt -t_srs EPSG:3857 -b [red] -b [green] -b [blue] newFile.vrt newFile.tif

If all your source TIFFs are also tiles, you can mosaic them in one step at the VRT stage too:

gdalbuildvrt -t_srs EPSG:3857 -b [red] -b [green] -b [blue] newFile.vrt my_folder/*.tif

It's also worth mentioning that gdal2tiles supports -s_srs arguments to define the source projection so you don't have to reproject the source image.

Marc Pfister
  • 4,097
  • 17
  • 11