BBBikeDownloader.download_subregion_data¶
-
BBBikeDownloader.
download_subregion_data
(subregion_name, download_dir=None, update=False, confirmation_required=True, verbose=False, ret_download_path=False)[source]¶ Download OSM data of all available formats for a geographic region.
- Parameters
subregion_name (str) – name of a geographic region (case-insensitive) available on BBBike’s free download server
download_dir (str or None) – directory where the downloaded file is saved, defaults to
None
update (bool) – whether to check on update and proceed to update the package data, defaults to
False
confirmation_required (bool) – whether to prompt a message for confirmation to proceed, defaults to
True
verbose (bool or int) – whether to print relevant information in console, defaults to
False
ret_download_path (bool) – whether to return the path(s) to the downloaded file(s), defaults to
False
- Returns
the path(s) to the downloaded file(s) when
ret_download_path=True
- Return type
list or str
Example:
>>> import os >>> from pyhelpers.dir import delete_dir >>> from pydriosm.downloader import BBBikeDownloader, cd_dat_bbbike >>> bbbike_downloader = BBBikeDownloader() >>> sr_name = 'london' >>> bbbike_downloader.download_subregion_data(sr_name, verbose=True) Confirmed to download all available BBBike OSM data of London? [No]|Yes: yes Downloading in progress ... London.osm.pbf ... London.osm.gz ... London.osm.shp.zip ... London.osm.garmin-onroad-latin1.zip ... London.osm.garmin-onroad.zip ... London.osm.garmin-opentopo.zip ... London.osm.garmin-osm.zip ... London.osm.geojson.xz ... London.osm.svg-osm.zip ... London.osm.mapsforge-osm.zip ... London.osm.navit.zip ... London.osm.csv.xz ... London.poly ... CHECKSUM.txt ... Done. Check out the downloaded OSM data at "\dat_BBBike\London". >>> # Delete the download directory generated above >>> delete_dir(cd_dat_bbbike(), verbose=True) The directory "\dat_BBBike" is not empty. Confirmed to delete it? [No]|Yes: yes Deleting "\dat_BBBike" ... Done. >>> sr_name = 'leeds' >>> dwnld_dir = "tests" >>> dwnld_paths = bbbike_downloader.download_subregion_data( ... sr_name, dwnld_dir, confirmation_required=False, verbose=True, ... ret_download_path=True) Downloading all available BBBike OSM data of Leeds ... Leeds.osm.pbf ... Leeds.osm.gz ... Leeds.osm.shp.zip ... Leeds.osm.garmin-onroad-latin1.zip ... Leeds.osm.garmin-onroad.zip ... Leeds.osm.garmin-opentopo.zip ... Leeds.osm.garmin-osm.zip ... Leeds.osm.geojson.xz ... Leeds.osm.svg-osm.zip ... Leeds.osm.mapsforge-osm.zip ... Leeds.osm.navit.zip ... Leeds.osm.csv.xz ... Leeds.poly ... CHECKSUM.txt ... Done. Check out the downloaded OSM data at "\tests\Leeds". >>> for dwnld_path in dwnld_paths: ... print(os.path.relpath(dwnld_path)) tests\Leeds\Leeds.osm.pbf tests\Leeds\Leeds.osm.gz tests\Leeds\Leeds.osm.shp.zip tests\Leeds\Leeds.osm.garmin-onroad-latin1.zip tests\Leeds\Leeds.osm.garmin-onroad.zip tests\Leeds\Leeds.osm.garmin-opentopo.zip tests\Leeds\Leeds.osm.garmin-osm.zip tests\Leeds\Leeds.osm.geojson.xz tests\Leeds\Leeds.osm.svg-osm.zip tests\Leeds\Leeds.osm.mapsforge-osm.zip tests\Leeds\Leeds.osm.navit.zip tests\Leeds\Leeds.osm.csv.xz tests\Leeds\Leeds.poly tests\Leeds\CHECKSUM.txt >>> # Delete the download directory generated above >>> delete_dir(os.path.dirname(dwnld_paths[0]), confirmation_required=False)