SeasoNet#

class torchgeo.datasets.SeasoNet(root='data', split='train', seasons=frozenset({'Fall', 'Snow', 'Spring', 'Summer', 'Winter'}), bands=('10m_RGB', '10m_IR', '20m', '60m'), grids=[1, 2], concat_seasons=1, transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

SeasoNet Semantic Segmentation dataset.

The SeasoNet dataset consists of 1,759,830 multi-spectral Sentinel-2 image patches, taken from 519,547 unique locations, covering the whole surface area of Germany. Annotations are provided in the form of pixel-level land cover and land usage segmentation masks from the German land cover model LBM-DE2018 with land cover classes based on the CORINE Land Cover database (CLC) 2018. The set is split into two overlapping grids, consisting of roughly 880,000 samples each, which are shifted by half the patch size in both dimensions. The images in each of the both grids themselves do not overlap.

Dataset format:

  • images are 16-bit GeoTiffs, split into separate files based on resolution

  • images include 12 spectral bands with 10, 20 and 60 m per pixel resolutions

  • masks are single-channel 8-bit GeoTiffs

Dataset classes:

  1. Continuous urban fabric

  2. Discontinuous urban fabric

  3. Industrial or commercial units

  4. Road and rail networks and associated land

  5. Port areas

  6. Airports

  7. Mineral extraction sites

  8. Dump sites

  9. Construction sites

  10. Green urban areas

  11. Sport and leisure facilities

  12. Non-irrigated arable land

  13. Vineyards

  14. Fruit trees and berry plantations

  15. Pastures

  16. Broad-leaved forest

  17. Coniferous forest

  18. Mixed forest

  19. Natural grasslands

  20. Moors and heathland

  21. Transitional woodland/shrub

  22. Beaches, dunes, sands

  23. Bare rock

  24. Sparsely vegetated areas

  25. Inland marshes

  26. Peat bogs

  27. Salt marshes

  28. Intertidal flats

  29. Water courses

  30. Water bodies

  31. Coastal lagoons

  32. Estuaries

  33. Sea and ocean

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

Added in version 0.5.

all_bands: tuple[str, ...] = ('10m_RGB', '10m_IR', '20m', '60m')#

Names of all available bands in the dataset

cmap: str | Colormap | None = <matplotlib.colors.ListedColormap object>#

Color map for the dataset

__init__(root='data', split='train', seasons=frozenset({'Fall', 'Snow', 'Spring', 'Summer', 'Winter'}), bands=('10m_RGB', '10m_IR', '20m', '60m'), grids=[1, 2], concat_seasons=1, transforms=None, download=False, checksum=False)[source]#

Initialize a new SeasoNet dataset instance.

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

  • split (Literal['train', 'val', 'test']) – one of “train”, “val” or “test”

  • seasons (Collection[str]) – list of seasons to load

  • bands (Iterable[str]) – list of bands to load

  • grids (Iterable[int]) – which of the overlapping grids to load

  • concat_seasons (int) – number of seasonal images to return per sample. if 1, each seasonal image is returned as its own sample, otherwise seasonal images are randomly picked from the seasons specified in seasons and returned as stacked tensors

  • 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:

DatasetNotFoundError – If dataset is not found and download is False.

__getitem__(index)[source]#

Return an index within the dataset.

Parameters:

index (int) – index to return

Returns:

sample at that index containing the image with shape TxCxHxW and the mask with shape HxW, where T = self.concat_seasons

Return type:

dict[str, Any]

__len__()[source]#

Return the number of data points in the dataset.

Returns:

length of the dataset

Return type:

int

__annotate_func__()#

The type of the None singleton.

plot(sample, show_titles=True, show_legend=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

  • show_legend (bool) – flag indicating whether to show a legend for the segmentation masks

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

Returns:

a matplotlib Figure with the rendered sample

Raises:

RGBBandsMissingError – If bands does not include all RGB bands.

Return type:

Figure