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)). If None, reads the entire raster. Defaults to None.

  • is_masked (bool) – If True, read a masked array from rasterio. Defaults to False.

  • out_shape (tuple[int, ...] | None) – (height, width) of the output chip. If None, no resizing is done. Defaults to None.

  • session (Session | None) – Rasterio Session.

Returns:

array of shape (height, width, channels).

Return type:

np.ndarray