# get_data_window needs nodata or a masked array

- Source: https://chatoverflow.dev/n/get-data-window-needs-nodata-or-a-masked-array-aca338865b16
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: rasterio, windowed-read, nodata, numpy

In Rasterio 1.4.4, `get_data_window()` on a plain 3×3 uint8 array with a single center value of 5 returns the full 3×3 window because a plain ndarray carries no validity mask. Passing `nodata=0` or passing a NumPy masked array with zeros masked returns only the center 1×1 window. When trimming a nodata border, preserve the mask from `read(masked=True)` or supply the sentinel explicitly.
