LandCover.ai Geo#
- class torchgeo.datasets.LandCoverAIBase(root='data', download=False, checksum=False)[source]#
Bases:
Dataset[dict[str,Any]],ABCAbstract base class for LandCover.ai Geo and NonGeo datasets.
The LandCover.ai (Land Cover from Aerial Imagery) dataset is a dataset for automatic mapping of buildings, woodlands, water and roads from aerial images. This implementation is specifically for Version 1 of LandCover.ai.
Dataset features:
land cover from Poland, Central Europe
three spectral bands - RGB
33 orthophotos with 25 cm per pixel resolution (~9000x9500 px)
8 orthophotos with 50 cm per pixel resolution (~4200x4700 px)
total area of 216.27 km2
Dataset format:
rasters are three-channel GeoTiffs with EPSG:2180 spatial reference system
masks are single-channel GeoTiffs with EPSG:2180 spatial reference system
Dataset classes:
building (1.85 km2)
woodland (72.02 km2)
water (13.15 km2)
road (3.5 km2)
If you use this dataset in your research, please cite the following paper:
Added in version 0.5.
- __init__(root='data', download=False, checksum=False)[source]#
Initialize a new LandCover.ai dataset instance.
- Parameters:
root (str | PathLike[str]) – root directory where dataset can be found
transforms – a function/transform that takes input sample and its target as entry and returns a transformed version
cache – 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)
- Raises:
DatasetNotFoundError – If dataset is not found and download is False.
- class torchgeo.datasets.LandCoverAIGeo(root='data', crs=None, res=None, transforms=None, cache=True, download=False, checksum=False, time_series=False)[source]#
Bases:
LandCoverAIBase,RasterDatasetLandCover.ai Geo dataset.
See the abstract LandCoverAIBase class to find out more.
Added in version 0.5.
- filename_glob = 'images/*.tif'#
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 = '.*tif'#
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
- __init__(root='data', crs=None, res=None, transforms=None, cache=True, download=False, checksum=False, time_series=False)[source]#
Initialize a new LandCover.ai NonGeo dataset instance.
- Parameters:
root (str | PathLike[str]) – root directory where dataset can be found
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 input sample and its target as entry 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.
- __getitem__(index)[source]#
Retrieve input, target, and/or metadata indexed by spatiotemporal slice.
- Parameters:
index (slice | tuple[slice] | tuple[slice, slice] | tuple[slice, slice, slice]) – [xmin:xmax:xres, ymin:ymax:yres, tmin:tmax:tres] coordinates to index.
- Returns:
Sample of input, target, and/or metadata at that index.
- Raises:
IndexError – If index is not found in the dataset.
- Return type: