transitio.MobilityDatabase.download

transitio.MobilityDatabase.download#

MobilityDatabase.download(dataset, directory=None, use_cache=True)#

Download a dataset zip with checksum verification and caching.

A dataset is a fixed version, so a cached copy holding it (its bytes matching the catalogued hash, when the catalogue gives one) is reused without a network request; use_cache=False downloads it again. Identical bytes catalogued as several datasets are stored once.

Parameters:
  • dataset (Dataset)

  • directory (str or pathlib.Path, optional) – When given, a writable copy is written to <directory>/<dataset id>.zip beside a .provenance.json sidecar recording feed and dataset IDs, source URL, checksum, service dates and retrieval time, and its path is returned. Otherwise the read-only cached file is returned; its sidecar describes the first dataset stored with these bytes.

  • use_cache (bool, default True) – Reuse a cached copy of the dataset.

Returns:

Path of the zip.

Return type:

pathlib.Path

Raises:

DownloadError – When the dataset has no hosted URL, its download fails (dropped connections and transient HTTP errors are retried first), its checksum does not match, or it is not a zip archive.