Global Mangrove Distribution#
- class torchgeo.datasets.CMSGlobalMangroveCanopy(paths='data', crs=None, res=None, measurement='agb', country='AndamanAndNicobar', transforms=None, cache=True, checksum=False, time_series=False)[source]#
Bases:
RasterDatasetCMS Global Mangrove Canopy dataset.
The CMS Global Mangrove Canopy dataset consists of a single band map at 30m resolution of either aboveground biomass (agb), basal area weighted height (hba95), or maximum canopy height (hmax95).
The dataset needs to be manually downloaded from the above link, where you can make an account and subsequently download the dataset.
Added in version 0.3.
- is_image = False#
True if the dataset only contains model inputs (such as images). False if the dataset only contains ground truth model outputs (such as segmentation masks).
The sample returned by the dataset/data loader will use the “image” key if is_image is True, otherwise it will use the “mask” key.
For datasets with both model inputs and outputs, the recommended approach is to use 2 RasterDataset instances and combine them using an IntersectionDataset.
- filename_regex = '^\n (?P<mangrove>[A-Za-z]{8})\n _(?P<variable>[a-z0-9]*)\n _(?P<country>[A-Za-z][^.]*)\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 calculatemintandmaxtforindexinsertionstart: used to calculatemintforindexinsertionstop: used to calculatemaxtforindexinsertion
When
separate_filesis True, the following additional groups are searched for to find other files:band: replaced with requested band name
- __init__(paths='data', crs=None, res=None, measurement='agb', country='AndamanAndNicobar', transforms=None, cache=True, checksum=False, time_series=False)[source]#
Initialize a new Dataset instance.
- Parameters:
paths (str | PathLike[str] | list[str | PathLike[str]]) – one or more root directories to search or 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 in (xres, yres) format. If a single float is provided, it is used for both the x and y resolution. (defaults to the resolution of the first file found)
measurement (str) – which of the three measurements, ‘agb’, ‘hba95’, or ‘hmax95’
country (str) – country for which to retrieve data
transforms (Callable[[dict[str, Any]], dict[str, Any]] | None) – a function/transform that takes an input sample and returns a transformed version
cache (bool) – if True, cache file handle to speed up repeated sampling
checksum (bool) – if True, check the MD5 of the downloaded files (may be slow)
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:
AssertionError – if country or measurement arg are not str or invalid
DatasetNotFoundError – If dataset is not found.
Added in version 0.9: The time_series parameter.
Changed in version 0.5: root was renamed to paths.