Esri2020#

class torchgeo.datasets.Esri2020(paths='data', crs=None, res=None, transforms=None, cache=True, download=False, checksum=False, time_series=False)[source]#

Bases: RasterDataset

Esri 2020 Land Cover Dataset.

The Esri 2020 Land Cover dataset consists of a global single band land use/land cover map derived from ESA Sentinel-2 imagery at 10m resolution with a total of 10 classes. It was published in July 2021 and used the Universal Transverse Mercator (UTM) projection. This dataset only contains labels, no raw satellite imagery.

The 10 classes are:

  1. No Data

  2. Water

  3. Trees

  4. Grass

  5. Flooded Vegetation

  6. Crops

  7. Scrub/Shrub

  8. Built Area

  9. Bare Ground

  10. Snow/Ice

  11. Clouds

A more detailed explanation of the individual classes can be found here.

If you use this dataset please cite the following paper:

Added in version 0.3.

is_image = False#

True if the dataset only contains model inputs (such as images). False if the dataset only contains ground truth model outputs (such as segmentation masks).

The sample returned by the dataset/data loader will use the “image” key if is_image is True, otherwise it will use the “mask” key.

For datasets with both model inputs and outputs, the recommended approach is to use 2 RasterDataset instances and combine them using an IntersectionDataset.

filename_glob = '*_20200101-20210101.*'#

Glob expression used to search for files.

This expression should be specific enough that it will not pick up files from other datasets. It should not include a file extension, as the dataset may be in a different file format than what it was originally downloaded as.

filename_regex = '^\n        (?P<id>[0-9][0-9][A-Z])\n        _(?P<date>\\d{8})\n        -(?P<processing_date>\\d{8})\n    '#

Regular expression used to extract date from filename.

The expression should use named groups. The expression may contain any number of groups. The following groups are specifically searched for by the base class:

  • date: used to calculate mint and maxt for index insertion

  • start: used to calculate mint for index insertion

  • stop: used to calculate maxt for index insertion

When separate_files is True, the following additional groups are searched for to find other files:

  • band: replaced with requested band name

__init__(paths='data', crs=None, res=None, transforms=None, cache=True, download=False, checksum=False, time_series=False)[source]#

Initialize a new Dataset instance.

Parameters:
  • paths (str | PathLike[str] | Iterable[str | PathLike[str]]) – one or more root directories to search or files to load

  • crs (CRS | None) – coordinate reference system (CRS) to warp to (defaults to the CRS of the first file found)

  • res (float | tuple[float, float] | None) – resolution of the dataset in units of CRS in (xres, yres) format. If a single float is provided, it is used for both the x and y resolution. (defaults to the resolution of the first file found)

  • transforms (Callable[[dict[str, Any]], dict[str, Any]] | None) – a function/transform that takes an input sample and returns a transformed version

  • cache (bool) – if True, cache file handle to speed up repeated sampling

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

  • time_series (bool) – if True, stack data along the time series dimension [T, C, H, W]. If False, merge data into a [C, H, W] mosaic.

Raises:

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

Added in version 0.9: The time_series parameter.

Changed in version 0.5: root was renamed to paths.

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

Plot a sample from the dataset.

Parameters:
  • sample (dict[str, Any]) – a sample returned by RasterDataset.__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