SustainBench Crop Yield#

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

Bases: NonGeoDataset

SustainBench Crop Yield Dataset.

This dataset contains MODIS band histograms and soybean yield estimates for selected counties in the USA, Argentina and Brazil. The dataset is part of the SustainBench datasets for tackling the UN Sustainable Development Goals (SDGs).

Dataset Format:

  • .npz files of stacked samples

Dataset Features:

  • input histogram of 7 surface reflectance and 2 surface temperature bands from MODIS pixel values in 32 ranges across 32 timesteps resulting in 32x32x9 input images

  • regression target value of soybean yield in metric tonnes per harvested hectare

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

Added in version 0.5.

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

Initialize a new Dataset instance.

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

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

  • countries (list[Literal['usa', 'brazil', 'argentina']]) – which countries to include in the dataset

  • transforms (Callable[[dict[str, Any]], dict[str, Any]] | None) – a function/transform that takes an input sample 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 after downloading files (may be slow)

Raises:
__len__()[source]#

Return the number of data points in the dataset.

Returns:

length of the dataset

Return type:

int

__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]

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

Plot a sample from the dataset.

Parameters:
  • sample (dict[str, Any]) – a sample return by __getitem__()

  • band_idx (int) – which of the nine histograms to index

  • show_titles (bool) – flag indicating whether to show titles above each panel

  • suptitle (str | None) – optional suptitle to use for figure

Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure