CropHarvest#

class torchgeo.datasets.CropHarvest(root='data', transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

CropHarvest dataset.

CropHarvest is a crop classification dataset.

Dataset features:

  • single pixel time series with crop-type labels

  • 18 bands per image over 12 months

Dataset format:

  • arrays are 12x18 with 18 bands over 12 months

Dataset properties:

  1. is_crop - whether or not a single pixel contains cropland

  2. classification_label - optional field identifying a specific crop type

  3. dataset - source dataset for the imagery

  4. lat - latitude

  5. lon - longitude

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

This dataset requires the following additional library to be installed:

  • h5py to load the dataset

Added in version 0.6.

all_bands: tuple[str, ...] = ('VV', 'VH', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B9', 'B11', 'B12', 'temperature_2m', 'total_precipitation', 'elevation', 'slope', 'NDVI')#

Names of all available bands in the dataset

rgb_bands: tuple[str, ...] = ('B4', 'B3', 'B2')#

Names of RGB bands in the dataset

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

Initialize a new CropHarvest dataset instance.

Parameters:
  • root (str | PathLike[str]) – root directory where dataset can be 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

  • 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:
__getitem__(index)[source]#

Return an index within the dataset.

Parameters:

index (int) – index to return

Returns:

single pixel time-series array 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, suptitle=None)[source]#

Plot a sample from the dataset using bands for Agriculture RGB composite.

Parameters:
Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure

__annotate_func__()#

The type of the None singleton.