Tuesday, 2 February 2016

gdal - gdalwarp's minimum resampling has no effect (possible bug)?


I'm attempting to use the minimum operator with gdalwarp v2.1.0 but it always mosaics as if I had selected nearest neighbor.


From the docs:


-r resampling_method:

min: minimum resampling, selects the minimum value from all non-NODATA contributing pixels. (GDAL >= 2.0.0)

The command is staightforward:


gdalwarp.exe -r min -srcnodata -9999 -dstnodata -9999 a.tif b.tif ... z.tif output.tif

But it gives me this output:


gdalwarp with minimum resampling - no effect


When what I expect is this (mosaicked through ArcMap with the minimum operator):


ArcMap's mosaic to new raster with minimum operator - expected output


This totally looks like a bug to me but I figured I'd ask here first in case I'm missing something.




Answer



I believe that gdalwarp does not handle multiple input files as a stack but it is processing them one by one so that the first image is warped into the target file first and pixels from the second one is added to the same target. If new pixels overlap existing ones they will simply be overwritten and the pixels from the last image will win the whole game.


The resampling options are applied to each image individually. "Contributing pixels" do not mean all contributing pixels from all the input files but contributing pixels from a.tif, then from b.tif and so on.



min: minimum resampling, selects the minimum value from all non-NODATA contributing pixels. (GDAL >= 2.0.0)



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...