[gdal-dev] Creating JPEGs with gdal2tiles using 4-band GeoTIFFs (RGB+NIR)

Even Rouault even.rouault at mines-paris.org
Sat Oct 22 03:09:56 EDT 2011


Le samedi 22 octobre 2011 06:22:04, Josh Doe a écrit :
> Hello,
> I've gotten 4-band imagery from USGS for Virginia, and it's stored in
> GeoTIFF format. The bands are R, G, B, and NIR. I tried running
> gdal2tiles directly on one of these files, and got a bad result, since
> it interpreted the NIR band as an alpha channel. I tried looking in
> the source to ignore this fourth band and just write out simple JPEGs
> using the first three bands, but couldn't figure out how to do so.
> Anyone else try this?
> 
> I was able to convert one file to just RGB using "gdal_translate -b 1
> -b 2 -b 3 ...", and then gdal2tiles was successful, however I have
> thousands of GeoTIFFs to work with and might not have the space to be
> converting the whole batch to eliminate the NIR band.

You can use your workaround, but instead of producing RGB TIFF, you can 
produce VRT files that are small XML files describing the transformation from 
R,G,B,NIR to R,G,B and that will be considered as valid raster by GDAL tools. 
You just have to add -of VRT to the gdal_translate command line. Then use 
gdal2tiles on those VRT files.

> 
> Thanks for any help,
> -Josh
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list