I would call this a bug in gdalwarp that it does not set the areas outside the -cutline
polygon to srcnodata
, but so something as random as zero.
An alternative solution that was proposed here "is to use gdal_translate
with -projwin
to extract to shape envelope and then gdal_rasterize
with -i
to burn nodata where shape is missing." This solution also circumvents raster shifting or resampling.