rasterio.sample module

rasterio.sample.sample_gen(dataset, xy, indexes=None, masked=False)

Sample pixels from a dataset

Parameters:
  • dataset (rasterio Dataset) – Opened in “r” mode.

  • xy (iterable) – Pairs of x, y coordinates in the dataset’s reference system.

  • indexes (int or list of int) – Indexes of dataset bands to sample.

  • masked (bool, default: False) – Whether to mask samples that fall outside the extent of the dataset.

Yields:

array – A array of length equal to the number of specified indexes containing the dataset values for the bands corresponding to those indexes.