DeepGlobe Land Cover#

class torchgeo.datasets.DeepGlobeLandCover(root='data', split='train', transforms=None, checksum=False)[source]#

Bases: NonGeoDataset

DeepGlobe Land Cover Classification Challenge dataset.

The DeepGlobe Land Cover Classification Challenge dataset offers high-resolution sub-meter satellite imagery focusing for the task of semantic segmentation to detect areas of urban, agriculture, rangeland, forest, water, barren, and unknown. It contains 1,146 satellite images of size 2448 x 2448 pixels in total, split into training/validation/test sets, the original dataset can be downloaded from Kaggle. However, we only use the training dataset with 803 images since the original test and valid dataset are not accompanied by labels. The dataset that we use with a custom train/test split can be downloaded from Kaggle (created as a part of Computer Vision by Deep Learning (CS4245) course offered at TU Delft).

Dataset format:

  • images are RGB data

  • masks are RGB image with with unique RGB values representing the class

Dataset classes:

  1. Urban land

  2. Agriculture land

  3. Rangeland

  4. Forest land

  5. Water

  6. Barren land

  7. Unknown

File names for satellite images and the corresponding mask image are id_sat.jpg and id_mask.png, where id is an integer assigned to every image.

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

Note

This dataset can be downloaded using:

$ pip install kaggle  # place api key at ~/.kaggle/kaggle.json
$ kaggle datasets download -d geoap96/deepglobe2018-landcover-segmentation-traindataset
$ unzip deepglobe2018-landcover-segmentation-traindataset.zip

Added in version 0.3.

__init__(root='data', split='train', transforms=None, checksum=False)[source]#

Initialize a new DeepGlobeLandCover dataset instance.

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

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

  • 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

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

Raises:

DatasetNotFoundError – If dataset is not found.

__getitem__(index)[source]#

Return an index within the dataset.

Parameters:

index (int) – index to return

Returns:

data and label at that index

Return type:

dict[str, Any]

__len__()[source]#

Return the number of data points in the dataset.

Returns:

length of the dataset

Return type:

int

plot(sample, show_titles=True, suptitle=None, alpha=0.5)[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

  • alpha (float) – opacity with which to render predictions on top of the imagery

Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure