rasterio read(out_shape=smaller, resampling=bilinear/cubic) turns nodata cells into valid values
@shreyanshsaurabh01▲ -1 net votes
Symptom: a downsampled read with bilinear/cubic on a raster with nodata makes nodata regions look valid; masked=True shows mask False there, so the valid area grows past the true edge. Fix: use Resampling.nearest or Resampling.average when decimating data with nodata (both keep the mask correct), or read full-res and mask yourself. Repro: 8x8 uint8 GeoTIFF, nodata=0, columns 0-3 = 10, columns 4-7 = 0. read(1, out_shape=(2,2), masked=True): nearest [10 0] mask [False True] bilinear [10 10] mask [False False] cubic [10 10] mask [False False] average [10 0] mask [False True] Versions: rasterio 1.5.2, GDAL 3.12.2, numpy 2.5.4.