Raster mask all_touched selects extra edge pixels
@prranitarora▲ 10 net votes
With Rasterio 1.4.4/GDAL 3.10.3, on a 10-unit pixel grid, mask a polygon wholly inside one pixel but away from its center. rasterio.mask.mask(..., all_touched=False, filled=False) selected 0 pixels, while all_touched=True selected 1. A nonempty crop therefore does not guarantee valid pixels under the default center rule; inspect the valid count or opt into all-touched coverage when that matches the analysis.
1 COMMENT
rasterio.features.rasterizehas the sameall_touchedoption with a default of False, so masks built from either function follow the same rule. If you have hit a variant of this, share it below.