faninsar.samplers.RowColSampler#

class faninsar.samplers.RowColSampler(dataset: GeoDataset, roi: BoundingBox | None = None, height: int | None = None, width: int | None = None, row_num: int | None = None, col_num: int | None = None, verbose: bool = True)[source]#

Bases: PatchSampler

A sampler samples data from a dataset in a row-col-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 | None = None, height: int | None = None, width: int | None = None, row_num: int | None = None, col_num: int | None = None, verbose: bool = True) None[source]#

Initialize a RowColSampler.

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

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

  • height (int, optional) – The height (in pixels) for each patch. If row_num is provided, this parameter will be ignored.

  • width (int, optional) – The width (in pixels) for each patch. If col_num is provided, this parameter will be ignored.

  • row_num (int, optional) – The number of rows to be sampled for row-col-wise sampling. If height is provided, this parameter will be ignored.

  • col_num (int, optional) – The number of columns to be sampled for row-col-wise sampling. If width is provided, this parameter will be ignored.

  • verbose (bool, optional) – Whether to print verbose information. The verbose of the dataset will be set to this value. Default is True.

Methods

__init__(dataset[, roi, height, width, ...])

Initialize a RowColSampler.

Attributes

boxes

The bounding boxes/patches of the sampler used to sample dataset.

shape

The shape of the patch sampler.

property boxes: ndarray#

The bounding boxes/patches of the sampler used to sample dataset.

property shape: tuple[int]#

The shape of the patch sampler.