[gdal-dev] Creating JPEGs with gdal2tiles using 4-band GeoTIFFs
(RGB+NIR)
Josh Doe
josh at joshdoe.com
Sat Oct 22 11:40:56 EDT 2011
On Sat, Oct 22, 2011 at 3:09 AM, Even Rouault
<even.rouault at mines-paris.org> wrote:
> 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, this worked perfectly! I used gdalbuildvrt on the thousands of
GeoTIFFs, then ran gdal_translate to pick out the R, G, and B bands to
create another VRT. I didn't realize until your message that you could
create a VRT from another VRT.
Thanks again,
-Josh
More information about the gdal-dev
mailing list