I am change the spatial reference system from raster file with gdalwarp. I would like to overwrite file to avoid own the same file again in my computer. I am trying to use gdalwarp with -overite parameter. But the error happened and I didn't understand why. I think that the path of input and output can be the same in order to do what I would like (not have the same file recorded). Is it possible to do with gdalwarp?

gdalwarp -overwrite /tmp/LC08_L1TP_215068_20160913_20170321_01_T1/LC08_L1TP_215068_20160913_20170321_01_T1_B8.TIF /tmp/LC08_L1TP_215068_20160913_20170321_01_T1/LC08_L1TP_215068_20160913_20170321_01_T1_B8.TIF -s_srs EPSG:32624 -t_srs EPSG:4674
ERROR 5: Source and destination datasets must be different.
  • Believe the error message. You can overwrite to an existing file but the input and output files cannot be the same. GDAL reads and writes data in chunks and it could easily happen that some pixels get updated before they have been read. If you want to save space and you are using some GDAL based software like QGIS you can use the virtual .VRT file as outputformat.
    – user30184
    Mar 16 '18 at 9:41

I don't think you can overwrite the input file. Why not carry out the processing and then delete the input file once it's complete?


gdalwarp myfile.TIF newfile.TIF -s_srs EPSG:32624 -t_srs EPSG:4674
del myfile.TIF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.