Dataset Samplers#

RowSampler#

class faninsar.samplers.RowSampler(dataset: GeoDataset, roi: BoundingBox | Sequence[float] | None = None, patch_size: int | None = None, patch_num: int | None = None, verbose: bool = False)#

Bases: object

A sampler samples data from a dataset in a row-wise manner.

This class is used to sample data from a dataset. The dataset is represented by a bounding box, and the sampler is used to sample data in the bounding box. The result of sampling is an iterator that yields data from the dataset.

__init__(dataset: GeoDataset, roi: BoundingBox | Sequence[float] | None = None, patch_size: int | None = None, patch_num: int | None = None, verbose: bool = False) None#

Initialize a sampler.

Parameters:
  • dataset (GeoDataset) – The dataset needs to be sampled.

  • roi (BoundingBox or Sequence, optional) – The the region of interest bounding box. If not provided, the bounding box of the dataset will be used.

  • patch_size (int, optional) –

    The size of the patch to be sampled for row-wise sampling in pixels. if not provided, the patch_num will be used.

    Note

    patch_size is a tuple of (height, width) in pixels. But in this class, only the height is used. The width is set to the width of the roi.

  • patch_num (int, optional) – The number of patches to be sampled for row-wise sampling. If patch_size is provided, this parameter will be ignored.

  • verbose (bool, optional) – Whether to print verbose information. Default is False.