[Gdal-dev] gdalwarp to merge several images

Frank Warmerdam warmerdam at pobox.com
Fri Nov 3 12:56:29 EST 2006


Nicolas Ribot wrote:
> Hello,
> 
> Refering to my previous post concerning gdal_merge.py, I now try to
> use gdalwarp to warp several input images to produce one target image.
> This target image is only a subset (a crop) of the the input images.
> 
> I noticed that when I call gdalwarp with several files, it reprojects
> all of them even if they don't overlap (after transformation) the
> target file bbox, leading to a very slow command when input files are
> big (1 Go each).
> 
> In my script, I wrote a test to exclude from input images all the
> images that don't intersect my target image (after having transformed
> bbox in the same system)
> 
> Is there a way to do it automatically with gdalwarp ?

Nicolas,

Looking in the code it seems there is an undocumented warp option called
SKIP_NOSOURCE that will cause gdalwarp to not attempt to actually warp
chunks where there is no input data.

eg
gdalwarp -wo SKIP_NOSOURCE=yes -te 400000 3720000 410000 3730000
      openev/utm.tif out.tif

I can't remember exactly why this isn't the default.  I think the issue
was that there was a risk of the output file not getting properly initialized
if blocks where skipped that shouldn't be skipped.   But I *think* it would
be safe for me to modify gdalwarp to set this option by default for the
second and subsequent files being processed.

Note the input files outside the target area were not actually having imagery
read.  But the warper was doing a great deal of work processing the whole
region only to discover none of the output pixels had any corresponding input
data.

Arg.  This does make gdalwarp a bit questionable for some mosaicing purposes.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list