BBBikeDownloader.get_valid_download_info

BBBikeDownloader.get_valid_download_info(subregion_name, osm_file_format, download_dir=None, **kwargs)[source]

Get information of downloading (or downloaded) data file.

The information includes a valid subregion name, a default filename, a URL and an absolute path where the data file is (to be) saved locally.

Parameters:
  • subregion_name (str) – name of a (sub)region available on BBBike free download server

  • osm_file_format (str) – file format/extension of the OSM data available on the download server

  • download_dir (str | None) – directory for saving the downloaded file(s), defaults to None; when download_dir=None, it refers to cdd_bbbike().

Returns:

valid subregion name, filename, download url and absolute file path

Return type:

tuple

Examples:

>>> from pydriosm.downloader import BBBikeDownloader
>>> import os
>>> bbd = BBBikeDownloader()
>>> subregion_name = 'birmingham'
>>> osm_file_format = "shp"
>>> # valid subregion name, filename, download url and absolute file path
>>> subregion_name_, pbf_filename, download_url, pbf_pathname =             ...     bbd.get_valid_download_info(subregion_name, osm_file_format)
>>> subregion_name_
'Birmingham'
>>> pbf_filename
'Birmingham.osm.shp.zip'
>>> download_url
'https://download.bbbike.org/osm/bbbike/Birmingham/Birmingham.osm.shp.zip'
>>> os.path.relpath(pbf_pathname)  # (on Windows)
'osm_data\bbbike\birmingham\Birmingham.osm.shp.zip'
>>> # Create a new instance with a given download directory
>>> bbd = BBBikeDownloader(download_dir="tests/osm_data")
>>> _, _, _, pbf_pathname = bbd.get_valid_download_info(subregion_name, osm_file_format)
>>> os.path.relpath(pbf_pathname)  # (Returns the same pathname on Windows)
'tests\osm_data\birmingham\Birmingham.osm.shp.zip'