I have a source HFA Erdas Imagine (.img) file which I'm trying to convert into tiles using gdal2tiles.py. I'm running:

gdal2tiles.py -w google -g GOOGLEKEY input_file.img

The HTML is generated correctly, and the tiles are correctly positioned. However, I'm getting black tiles instead of the actual content of the .img file:

wrong tiles

I've verified (using QGis and MapTiler) that the .img contains the correct data, i.e. the source file has raster data.

Any ideas? Should I transform the .img to something else? Am I missing an option for the command?

  • Does gdaldem work if the .IMG has no elevation data ? <br /> I tried it using the color ramp below and the output file was all green. 0 110 220 110 900 240 250 160 1300 230 220 170 1900 220 220 220 2500 250 250 250 This is because the height for all raster cells are the same, 0. <br/> Which color ramp should i use with gdaldem to prevent gdal2tiles.py from generating dark pngs ? <br/> Is there another hack ? <br/><br/> Thanks, <br/> Allan. – Allan Oware Jul 10 '14 at 12:43

It seems the tiles were generated correctly, with very dark subtle shades of gray.

What it did then was first apply a color table for each value of my raster:

gdaldem color-relief input_file.img color_table output_file.tiff

where color_table is a file describing a custom color table:

1    red
2    green
3    blue
4    yellow
5    0 0 0 0
nv   black

And then I generated the tiles with the generated .tiff:

gdal2tiles.py -z 2-11 -w google -g GOOGLEAPIKEY output_file.tiff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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