AgriFieldNet#
- class torchgeo.datasets.AgriFieldNet(paths='data', crs=None, res=None, classes=[0, 1, 2, 3, 4, 5, 6, 8, 9, 13, 14, 15, 16, 36], bands=('B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B11', 'B12'), transforms=None, cache=True, download=False, time_series=False)[source]#
Bases:
IntersectionDatasetAgriFieldNet India Challenge dataset.
The AgriFieldNet India Challenge dataset includes satellite imagery from Sentinel-2 cloud free composites (single snapshot) and labels for crop type that were collected by ground survey. The Sentinel-2 data are then matched with corresponding labels. The dataset contains 7081 fields, which have been split into training and test sets (5551 fields in the train and 1530 fields in the test). Satellite imagery and labels are tiled into 256x256 chips adding up to 1217 tiles. The fields are distributed across all chips, some chips may only have train or test fields and some may have both. Since the labels are derived from data collected on the ground, not all the pixels are labeled in each chip. If the field ID for a pixel is set to 0 it means that pixel is not included in either of the train or test set (and correspondingly the crop label will be 0 as well). For this challenge train and test sets have slightly different crop type distributions. The train set follows the distribution of ground reference data which is a skewed distribution with a few dominant crops being over represented. The test set was drawn randomly from an area weighted field list that ensured that fields with less common crop types were better represented in the test set. The original dataset can be downloaded from Source Cooperative.
Dataset format:
images are 12-band Sentinel-2 data
masks are tiff images with unique values representing the class and field id
Dataset classes:
No-Data
Wheat
Mustard
Lentil
No Crop/Fallow
Green pea
Sugarcane
Garlic
Maize
Gram
Coriander
Potato
Berseem
Rice
If you use this dataset in your research, please cite the following dataset:
Note
This dataset requires the following additional library to be installed:
azcopy: to download the dataset from Source Cooperative.
Added in version 0.6.
- __init__(paths='data', crs=None, res=None, classes=[0, 1, 2, 3, 4, 5, 6, 8, 9, 13, 14, 15, 16, 36], bands=('B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B11', 'B12'), transforms=None, cache=True, download=False, time_series=False)[source]#
Initialize a new AgriFieldNet dataset instance.
- Parameters:
paths (str | PathLike[str] | Iterable[str | PathLike[str]]) – one or more root directories to search for files to load
crs (CRS | None) – coordinate reference system (CRS) to warp to (defaults to the CRS of the first file found)
res (float | tuple[float, float] | None) – resolution of the dataset in units of CRS (defaults to the resolution of the first file found)
classes (list[int]) – list of classes to include, the rest will be mapped to 0 (defaults to all classes)
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
cache (bool) – if True, cache the dataset in memory
download (bool) – if True, download dataset and store it in the root directory
time_series (bool) – if True, stack data along the time series dimension [T, C, H, W]. If False, merge data into a [C, H, W] mosaic.
- Raises:
DatasetNotFoundError – If dataset is not found and download is False.
Added in version 0.10: The res parameter.
Added in version 0.9: The time_series parameter.
- __getitem__(index)[source]#
Retrieve input, target, and/or metadata indexed by spatiotemporal slice.
- Parameters:
index (slice | tuple[slice] | tuple[slice, slice] | tuple[slice, slice, slice]) – [xmin:xmax:xres, ymin:ymax:yres, tmin:tmax:tres] coordinates to index.
- Returns:
Sample of input, target, and/or metadata at that index.
- Raises:
IndexError – If index is not found in the dataset.
- Return type:
- plot(sample, show_titles=True, suptitle=None)[source]#
Plot a sample from the dataset.
- Parameters:
- Returns:
a matplotlib Figure with the rendered sample
- Raises:
RGBBandsMissingError – If bands does not include all RGB bands.
- Return type: