USAVars#

class torchgeo.datasets.USAVars(root='data', split='train', labels=('treecover', 'elevation', 'population'), transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

USAVars dataset.

The USAVars dataset is reproduction of the dataset used in the paper “A generalizable and accessible approach to machine learning with global satellite imagery”. Specifically, this dataset includes 1 sq km. crops of NAIP imagery resampled to 4m/px cenetered on ~100k points that are sampled randomly from the contiguous states in the USA. Each point contains three continuous valued labels (taken from the dataset released in the paper): tree cover percentage, elevation, and population density.

Dataset format:

  • images are 4-channel GeoTIFFs

  • labels are singular float values

Dataset labels:

  • tree cover

  • elevation

  • population density

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

Added in version 0.3.

__init__(root='data', split='train', labels=('treecover', 'elevation', 'population'), transforms=None, download=False, checksum=False)[source]#

Initialize a new USAVars dataset instance.

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

  • split (str) – train/val/test split to load

  • labels (Sequence[str]) – list of labels to include

  • 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:

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_labels=True, suptitle=None)[source]#

Plot a sample from the dataset.

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

  • show_labels (bool) – flag indicating whether to show labels above panel

  • suptitle (str | None) – optional string to use as a suptitle

Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure

__annotate_func__()#

The type of the None singleton.