Fields Of The World#

class torchgeo.datasets.FieldsOfTheWorld(root='data', split='train', target='2-class', countries=['austria'], transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

Fields Of The World dataset.

The Fields Of The World datataset is a semantic and instance segmentation dataset for delineating field boundaries.

Dataset features:

  • 70462 patches across 24 countries

  • Each country has a train, val, and test split

  • Semantic segmentations masks with and without the field boundary class

  • Instance segmentation masks

Dataset format:

  • images are four-channel GeoTIFFs with dimension 256x256

  • segmentation masks (both two and three class) are single-channel GeoTIFFs

  • instance masks are single-channel GeoTIFFs

Dataset classes:

  1. background

  2. field

  3. field-boundary (three-class only)

  4. unlabeled (kenya, rwanda, brazil and india have presence only labels)

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

Added in version 0.7.

__init__(root='data', split='train', target='2-class', countries=['austria'], transforms=None, download=False, checksum=False)[source]#

Initialize a new Fields Of The World dataset instance.

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

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

  • target (Literal['2-class', '3-class', 'instance']) – one of “2-class”, “3-class”, or “instance” specifying which kind of target mask to load

  • countries (str | Sequence[str]) – which set of countries to load data from

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

image and mask at that index with image of dimension 3x1024x1024 and mask of dimension 1024x1024

Return type:

dict[str, Any]

__len__()[source]#

Return the number of datapoints in the dataset.

Returns:

length of dataset

Return type:

int

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

Plot a sample from the dataset.

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

  • 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

__annotate_func__()[source]#

The type of the None singleton.