Landsat#
- class torchgeo.datasets.Landsat(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
RasterDataset,ABCAbstract base class for all Landsat datasets.
Landsat is a joint NASA/USGS program, providing the longest continuous space-based record of Earth’s land in existence.
If you use this dataset in your research, please cite it using the following format:
If you use any of the following Level-2 products, there may be additional citation requirements, including papers you can cite. See the “Citation Information” section of the following pages:
- filename_regex = '\n ^L\n (?P<sensor>[COTEM])\n (?P<satellite>\\d{2})\n _(?P<processing_correction_level>[A-Z0-9]{4})\n _(?P<wrs_path>\\d{3})\n (?P<wrs_row>\\d{3})\n _(?P<date>\\d{8})\n _(?P<processing_date>\\d{8})\n _(?P<collection_number>\\d{2})\n _(?P<collection_category>[A-Z0-9]{2})\n _(?P<band>[A-Z0-9_]+)\n \\.\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 calculatemintandmaxtforindexinsertionstart: used to calculatemintforindexinsertionstop: used to calculatemaxtforindexinsertion
When
separate_filesis True, the following additional groups are searched for to find other files:band: replaced with requested band name
- separate_files = True#
True if data is stored in a separate file for each band, else False.
- __init__(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, 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)
bands (Sequence[str] | None) – bands to return (defaults to all bands)
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
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:
- Returns:
a matplotlib Figure with the rendered sample
- Raises:
RGBBandsMissingError – If bands does not include all RGB bands.
- Return type:
Changed in version 0.3: Method now takes a sample dict, not a Tensor. Additionally, possible to show subplot titles and/or use a custom suptitle.
- __annotate_func__()#
The type of the None singleton.
- class torchgeo.datasets.Landsat9(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
Landsat8Landsat 9 Operational Land Imager (OLI-2) and Thermal Infrared Sensor (TIRS-2).
- filename_glob = 'LC09_*_{}.*'#
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.
- class torchgeo.datasets.Landsat8(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
LandsatLandsat 8 Operational Land Imager (OLI) and Thermal Infrared Sensor (TIRS).
- filename_glob = 'LC08_*_{}.*'#
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.
- class torchgeo.datasets.Landsat7(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
LandsatLandsat 7 Enhanced Thematic Mapper Plus (ETM+).
- filename_glob = 'LE07_*_{}.*'#
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.
- class torchgeo.datasets.Landsat5TM(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
Landsat4TMLandsat 5 Thematic Mapper (TM).
- filename_glob = 'LT05_*_{}.*'#
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.
- class torchgeo.datasets.Landsat5MSS(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
Landsat4MSSLandsat 4 Multispectral Scanner (MSS).
- filename_glob = 'LM04_*_{}.*'#
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.
- class torchgeo.datasets.Landsat4TM(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
LandsatLandsat 4 Thematic Mapper (TM).
- filename_glob = 'LT04_*_{}.*'#
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.
- class torchgeo.datasets.Landsat4MSS(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
LandsatLandsat 4 Multispectral Scanner (MSS).
- filename_glob = 'LM04_*_{}.*'#
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.
- class torchgeo.datasets.Landsat3(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
Landsat1Landsat 3 Multispectral Scanner (MSS).
- filename_glob = 'LM03_*_{}.*'#
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.
- class torchgeo.datasets.Landsat2(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
Landsat1Landsat 2 Multispectral Scanner (MSS).
- filename_glob = 'LM02_*_{}.*'#
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.
- class torchgeo.datasets.Landsat1(paths='data', crs=None, res=None, bands=None, transforms=None, cache=True, time_series=False)[source]#
Bases:
LandsatLandsat 1 Multispectral Scanner (MSS).
- filename_glob = 'LM01_*_{}.*'#
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.