I'm attempting to down-sample a raster (resampling to a coarser/ larger pixel size) with continuous, floating-point values. I generally use bilinear resampling for the up-sampling case (resampling to a finer resolution), so I thought I would use it here, too. I'm finding that whether I use
gdal.Warp (which is a wrapper for
gdalwarp), I get large NoData chunks in the output image wherever there was at least one NoData value in the input image. I would have assumed that as long as there was some data in an output pixel (which subsumes multiple smaller pixels), there would be a valid output value.
Sample Python code used to resample the original equal-area raster is below; there is an equivalent with
gdal.ReprojectImage() but it is much more verbose.
import gdal from gdal import gdalconst ds = gdal.Warp( 'temp.file', original_raster, format = 'MEM', xRes = 1, yRes = 1, dstSRS = "EPSG:4326", outputBounds = (-179.5, -90.5, 180.5, 89.5), resampleAlg = gdalconst.GRA_Bilinear, outputType = gdalconst.GDT_Float32)
In contrast, a nearest-neighbor resampling (changing
resampleAlg argument) produces a continuous 1-degree grid, with no "holes" in the output raster. Nearest neighbor is much simpler, of course, but is there an option to calculate weights for bilinear resampling in a way that NoData pixels don't contaminate output pixels in this way?