read_window#
- read_window(dataset: DatasetReader, bands: Optional[Union[int, Sequence[int]]] = None, window: tuple[tuple[int, int], tuple[int, int]] | None = None, is_masked: bool = False, out_shape: tuple[int, ...] | None = None, session: Session | None = None) ndarray [source]#
Load a window of an image using Rasterio.
- Parameters:
dataset (DatasetReader) – a Rasterio dataset.
bands (Optional[Union[int, Sequence[int]]]) – Band index or indices to read. Must be 1-indexed.
window (tuple[tuple[int, int], tuple[int, int]] | None) –
((row_start, row_stop), (col_start, col_stop))
or((y_min, y_max), (x_min, x_max))
. IfNone
, reads the entire raster. Defaults toNone
.is_masked (bool) – If
True
, read a masked array from rasterio. Defaults toFalse
.out_shape (tuple[int, ...] | None) – (height, width) of the output chip. If
None
, no resizing is done. Defaults toNone
.session (Session | None) – Rasterio
Session
.
- Returns:
array of shape (height, width, channels).
- Return type:
np.ndarray