EuroCrops#
- class torchgeo.datasets.EuroCrops(paths='data', crs=None, res=(1e-05, 1e-05), classes=None, transforms=None, download=False, checksum=False)[source]#
Bases:
VectorDatasetEuroCrops Dataset (Version 9).
The EuroCrops dataset combines “all publicly available self-declared crop reporting datasets from countries of the European Union” into a unified format. The dataset is released under CC BY 4.0 Deed.
The dataset consists of shapefiles containing a total of 22M polygons. Each polygon is tagged with a “EC_hcat_n” attribute indicating the harmonized crop name grown within the polygon in the year associated with the shapefile.
If you use this dataset in your research, please follow the citation guidelines at:
Added in version 0.6.
- filename_glob = '*_EC*.shp'#
Glob expression used to search for files.
This expression should be specific enough that it will not pick up files from other datasets. It should not include a file extension, as the dataset may be in a different file format than what it was originally downloaded as.
- filename_regex = '\n ^(?P<country>[A-Z]{2})\n (_(?P<region>[A-Z]+))?\n _\n (?P<date>\\d{4})\n _\n (?P<suffix>EC(?:21)?)\n \\.shp$\n '#
Regular expression used to extract date from filename.
The expression should use named groups. The expression may contain any number of groups. The following groups are specifically searched for by the base class:
date: used to calculatemintandmaxtforindexinsertion
- date_format = '%Y'#
Date format string used to parse date from filename.
Not used if
filename_regexdoes not contain adategroup.
- __init__(paths='data', crs=None, res=(1e-05, 1e-05), classes=None, transforms=None, download=False, checksum=False)[source]#
Initialize a new EuroCrops 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 WGS-84)
res (float | tuple[float, float]) – resolution of the dataset in units of CRS in (xres, yres) format. If a single float is provided, it is used for both the x and y resolution.
classes (list[str] | None) – list of classes to include (specified by their HCAT code), 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 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 of the downloaded files (may be slow)
- Raises:
DatasetNotFoundError – If dataset is not found and download is False.
- __annotate_func__()#
The type of the None singleton.