Canadian Building Footprints#

class torchgeo.datasets.CanadianBuildingFootprints(paths='data', crs=None, res=(1e-05, 1e-05), transforms=None, download=False, checksum=False)[source]#

Bases: VectorDataset

Canadian Building Footprints dataset.

The Canadian Building Footprints dataset contains 11,842,186 computer generated building footprints in all Canadian provinces and territories in GeoJSON format. This data is freely available for download and use.

filename_glob = '*.geojson'#

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.

__init__(paths='data', crs=None, res=(1e-05, 1e-05), transforms=None, download=False, checksum=False)[source]#

Initialize a new Dataset instance.

Parameters:
  • paths (str | PathLike[str] | Iterable[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]) – 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.

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

Changed in version 0.5: root was renamed to paths.

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

Plot a sample from the dataset.

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

  • show_titles (bool) – flag indicating whether to show titles above each panel

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

Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure

Changed in version 0.3: Method now takes a sample dict, not a Tensor. Additionally, it is possible to show subplot titles and/or use a custom suptitle.