S2-100k#

class torchgeo.datasets.S2100k(root='data', *, mode='both', transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

S2-100K dataset.

The S2-100k dataset contains 100,000 256x256 patches of 12 band Sentinel imagery sampled randomly from Sentinel 2 scenes on the Microsoft Planetary Computer that have <20% cloud cover, intersect land, and were captured between 2021-01-01 and 2023-05-17 (there are 2,359,972 such scenes).

If you use this dataset in your research, please cite the following paper:

Added in version 0.10.

__init__(root='data', *, mode='both', transforms=None, download=False, checksum=False)[source]#

Initialize a new S2100K dataset instance.

Parameters:
  • root (str | PathLike[str]) – Root directory where dataset can be found.

  • mode (Literal['both', 'points']) – Which data to return (options are “both” or “points”), useful for embedding locations without loading images.

  • transforms (Callable[[dict[str, Any]], dict[str, Any]] | None) – A function/transform that takes input sample and its target as entry and returns a transformed version.

  • download (bool) – If True, download dataset and store it in the root directory.

  • checksum (bool) – If True, check the MD5 of the downloaded files (may be slow).

Raises:
__getitem__(index)[source]#

Return an index within the dataset.

Parameters:

index (int) – Index to return.

Returns:

Dictionary with “image” and “point” keys where point is in (lon, lat) format.

Return type:

dict[str, Any]

__len__()[source]#

Return the number of datapoints in the dataset.

Returns:

Length of the dataset.

Return type:

int

plot(sample, show_titles=True, suptitle=None)[source]#

Plot a sample from the dataset.

Parameters:
  • sample (dict[str, Any]) – A sample returned by __getitem__().

  • show_titles (bool) – Flag indicating whether to show titles above each panel.

  • suptitle (str | None) – Optional string to use as a suptitle.

Returns:

A matplotlib Figure with the rendered sample.

Return type:

Figure