[gdal-dev] Re: Strange behavior of gdalwarp with -overwrite option
even.rouault at mines-paris.org
Tue Nov 8 14:28:40 EST 2011
Le mardi 08 novembre 2011 19:18:19, Jukka Rahkonen a écrit :
> Alexander Bruy <alexander.bruy <at> gmail.com> writes:
> > Hi all,
> > in gdalwarp documentation  listed option "-overwrite" with next
> > description:
> > -overwrite:
> > (GDAL >= 1.8.0) Overwrite the target dataset if it already exists.
> > But when I try to reproject image using next command
> > gdalwarp -t_srs EPSG:4326 -overwrite mosaic.tif mosaic.tif
> > i get next error
> > Creating output file that is 9122P x 2341L.
> > ERROR 4: `mosaic.tif' not recognised as a supported file format.
> > and mosaic.tif becomes 8 bytes size file (seems only tif header).
> > Is this bug or I misunderstand -overwrite option usage?
> > Tested on Slackware 13.37, GDAL 1.8.1, released 2011/07/09.
> >  http://www.gdal.org/gdalwarp.html
I'm not a native English speaker, but up to now, the meaning of "overwrite"
has always been "delete and recreate". If you have a better wording for the
doc to make it more explicit, you're welcome.
The point of overwrite is that it is a common source of confusion for users
(including me!) when you do :
gdalwarp src.tif dest.tif -t_srs EPSG:XXXX
and then you realize that XXXX is not what you want. So you try:
gdalwarp src.tif dest.tif -t_srs EPSG:YYYY
And you spend half and hour understanding why it has not been reprojected in
EPSG:YYYY. The default behaviour being that once the target dataset exists, it
is only updated, but not modified in depth.
gdalwarp something.tif something.tif -t_srs EPSG:XXXX makes no sense, with or
without -overwrite (and -overwrite will actually kill your target, ahem,
source - since source=target - as you have seen !). Reprojection in place
cannot work. You must specify a different target dataset. I can imagine that a
safety check would make sense to detect such obvious error...
> I bet you do not really want to overwrite the source image with the target
> image because it will make you sad. Once gdal has written a beginning of
> the target "mosaic.tif" you have deleted the original "mosaic.tif" and
> there is nothing more to convert. Put that command into a patch file and
> you can wipe a few hundred originals in some seconds so effectively that
> even data recovery companies cannot get them back. I've tried it and I do
> not recommend it for anybody else.
> Gdalwarp -overwrite source.tif target.tif should overwrite the old existing
> target.tif and that is a reasonable command sometimes.
> -Jukka Rahkonen-
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
More information about the gdal-dev