Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5909 closed defect (fixed)

multiple gdalwarp invocations only preserves last image, when input has nodata

Reported by: Robert Coup Owned by: Even Rouault
Priority: high Milestone: 1.11.3
Component: GDAL_Raster Version: 1.11.2
Severity: normal Keywords: warp
Cc:

Description (last modified by Robert Coup)

somewhere between these two revisions (github:OSGeo/gdal/trunk), multiple gdalwarp invocations to the same output seem to end up with only the final input file's contents.

Good: e6cdad5a884f18e16c3660300d0fae542ff10a1b Bad: 4418c47ad62a42363357e03a33ecab674e6ac973

Built with JP2KAK, which it's using for the below.

Output changes (out.oldgdal.tif => correct, out.newgdal.tif => wrong):

gdalwarp '-multi' '-of' 'GTiff' '-co' 'TILED=YES' '-co' 'BIGTIFF=IF_SAFER' \
  '-te' '174.255653381' '-36.1153205766' '174.290066734' '-36.1101806196' \
  '-dstalpha' '-wo' 'INIT_DEST=0,0,0,0' '-ts' '4480' '669' \
  '-s_srs' '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +wktext' \
  '-t_srs' '+proj=longlat +datum=WGS84 +no_defs +wktext' \
  '--config' 'GDAL_CACHEMAX' '128' '-wm' '128' '-r' 'cubic' \
  '00000010.jp2' 'out.tif'

gdalwarp '-multi' '-s_srs' '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +wktext' \
  '-t_srs' '+proj=longlat +datum=WGS84 +no_defs +wktext' \
  '--config' 'GDAL_CACHEMAX' '128' '-wm' '128' '-r' 'cubic' \
  '0000001e.jp2' 'out.tif'

Possibly relevant commits from a quick look, still working through them, and trying to simplify the test case:

  • Those relating to #5387
  • 3793b0e (JP2KAK)

Change History (5)

comment:1 by Robert Coup, 9 years ago

Description: modified (diff)

Argh, file upload issues. Dropbox link coming soon

comment:2 by Even Rouault, 9 years ago

Robert,

I've tried something quite similar to your attempt, and I don't find issue (which I'm rather happy since #5837 went into the stable branch). So your issue must be something more subtle...

Preparation steps to cut a RGB raster in 2 halves:

cp ../autotest/gdrivers/data/small_world.tif .
gdal_translate small_world.tif small_world_left.tif -srcwin 0 0 200 200
gdal_translate small_world.tif small_world_right.tif -srcwin 200 0 200 200

Merging them together :

gdalwarp small_world_left.tif out.tif -overwrite -te -180 -90 180 90 -dstalpha -wo "INIT_DEST=0,0,0,0"
gdalwarp small_world_right.tif out.tif

I've also testing something closer to your attempt (reprojection, tiling, bigger output size), but still working OK :

gdalwarp small_world_left.tif out.tif -overwrite -te -20000000 -20000000 20000000 20000000  -dstalpha -wo "INIT_DEST=0,0,0,0" -s_srs EPSG:4326 -t_srs EPSG:3857 -ts 4000 4000 -co tiled=yes
gdalwarp small_world_right.tif out.tif -s_srs EPSG:4326 -t_srs EPSG:3857

comment:3 by Robert Coup, 9 years ago

Hi Even, sorry for the delay. Sample data (source & output) is at https://dl.dropboxusercontent.com/u/726114/sample-data.zip

comment:4 by Even Rouault, 9 years ago

Keywords: warp added
Milestone: 1.11.3
Resolution: fixed
Status: newclosed
Summary: multiple gdalwarp invocations only preserves last imagemultiple gdalwarp invocations only preserves last image, when input has nodata
Version: svn-trunk1.11.2

trunk r28832, branches/1.11 r28834 "gdalwarp: fix trunk/1.11.2 regression when invoking several times gdalwarp with several input files on the same target file, and when the input files have a nodata setting: only the last input file was warped onto the target dataset (#5909)"

comment:5 by Robert Coup, 9 years ago

Tests out okay for me, thanks Even :)

Note: See TracTickets for help on using tickets.