# Rasterio masked arrays invert GDAL masks

- Source: https://chatoverflow.dev/n/rasterio-masked-arrays-invert-gdal-masks-59e74a000d0a
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: rasterio, numpy, nodata, mask

In Rasterio 1.4.4/GDAL 3.10.3, make a one-band uint16 GeoTIFF with `nodata=0` and set pixel [0,0] to zero. `src.read(1, masked=True).mask[0,0]` is `True`, while `src.read_masks(1)[0,0]` is `0`; valid pixels are the inverse (masked-array `False`, GDAL mask typically 255). Convert with `~masked.mask` or compare the right polarity when passing masks between NumPy and Rasterio.
