[gdal-dev] How do I select 3 of 5 bands for output?
Stephen Woodbridge
woodbri at swoodbridge.com
Fri Nov 7 17:44:41 EST 2008
Lucena, Ivan wrote:
> Hi Steve,
>
>> I have a script that was processing MrSID files and need to convert it
>> to support jp2 files also. It seems pretty straight forward except the
>> jp2 files have bands R,G,B,IR and I need to chop these into GeoTif tiles
>> with only R,G,B bands.
>>
>> The script was iterating over the src image and chopping it into tiles
>> using the following command:
>>
>> system("gdalwarp -srcnodata 0 -dstnodata 0 -s_srs +init=epsg:$epsg
>> -t_srs EPSG:4326 -te $xm $ym $xx $yx -rb -wm 250 --config
>> GDAL_ONE_BIG_READ ON -co "TILED=YES" $infile $work/$outd/$outf\n");
>>
>> 1) How does this behave with R,G,B,IR as input and how can I get R,G,B
>> only into the GeoTif?
>
> I would add one call to gdal_translate with "-b 1 -b 2 -b 3" first to build a VRT and then call gdalwarp from the VRT.
>
> {
> system("gdaltranslate $infile -b 1 -b 2 -b 3 tmp.vrt");
> system("gdalwarp -srcnodata 0 -dstnodata 0 -s_srs +init=epsg:$epsg -t_srs EPSG:4326 -te $xm $ym $xx $yx -rb -
> wm 250 --config GDAL_ONE_BIG_READ ON -co "TILED=YES" tmp.vrt $work/$outd/$outf\n");
> }
> system("gdalmanage delete tmp.vrt");
OK, this might work, but it is incredibly slow. Then again probably
doing much of anything with these images will be slow because they are
HUGE. So looking for ways to speed this up. It looks like the .vrt file
is really a GeoTif would it help later if the .vrt was made with -co
"TILED=YES", can you do this with a .vrt file. I think the uncompressed
3 band geoTif will be in the ballpark of 10GB, is this being made as a
BigTiff? or will I run into problems when I hit the 2GB limit?
Anyway to get this to go faster? CPU is at 101%, 78MB of memory is being
used, I have LOTS more if I can get gdal to use it.
-Steve
More information about the gdal-dev
mailing list