BBBikeDownloader.download_subregion_data¶
-
BBBikeDownloader.
download_subregion_data
(subregion_name, download_dir=None, update=False, confirmation_required=True, interval=None, verbose=False, ret_download_path=False, **kwargs)¶ Download OSM data of all available formats for a geographic region.
- Parameters
subregion_name (str) – name of a geographic region available on BBBike free download server
download_dir (str or None) – directory where the downloaded file is saved, defaults to
None
update (bool) – whether to update the data if it already exists, defaults to
False
confirmation_required (bool) – whether asking for confirmation to proceed, defaults to
True
interval (int or None) – interval (in second) between downloading two subregions, defaults to
None
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
kwargs – optional parameters of pyhelpers.ops.download_file_from_url()
- Returns
the path(s) to the downloaded file(s) when
ret_download_path
isTrue
- 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() >>> # Download the BBBike OSM data of London >>> region_name = 'london' >>> bbbike_downloader.download_subregion_data(region_name, verbose=True) To download all available BBBike OSM data of London ? [No]|Yes: yes Downloading: London.osm.pbf ... Done. London.osm.gz ... Done. London.osm.shp.zip ... Done. London.osm.garmin-onroad-latin1.zip ... Done. London.osm.garmin-onroad.zip ... Done. London.osm.garmin-opentopo.zip ... Done. London.osm.garmin-osm.zip ... Done. London.osm.geojson.xz ... Done. London.osm.svg-osm.zip ... Done. London.osm.mapsforge-osm.zip ... Done. London.osm.navit.zip ... Done. London.osm.csv.xz ... Done. London.poly ... Done. CHECKSUM.txt ... Done. Check out the downloaded OSM data at "osm_bbbike\London\". >>> # Delete the download directory generated above >>> delete_dir(cd_dat_bbbike(), verbose=True) The directory "osm_bbbike\" is not empty. Confirmed to delete it? [No]|Yes: yes Deleting "osm_bbbike\" ... Done. >>> # Download the BBBike OSM data of Leeds >>> region_name = 'leeds' >>> dwnld_dir = "tests" >>> dwnld_paths = bbbike_downloader.download_subregion_data( ... region_name, dwnld_dir, confirmation_required=False, verbose=True, ... ret_download_path=True) Downloading all available BBBike OSM data of Leeds: Leeds.osm.pbf ... Done. Leeds.osm.gz ... Done. Leeds.osm.shp.zip ... Done. Leeds.osm.garmin-onroad-latin1.zip ... Done. Leeds.osm.garmin-onroad.zip ... Done. Leeds.osm.garmin-opentopo.zip ... Done. Leeds.osm.garmin-osm.zip ... Done. Leeds.osm.geojson.xz ... Done. Leeds.osm.svg-osm.zip ... Done. Leeds.osm.mapsforge-osm.zip ... Done. Leeds.osm.navit.zip ... Done. Leeds.osm.csv.xz ... Done. Leeds.poly ... Done. 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.commonpath(dwnld_paths), verbose=True) The directory "tests\Leeds\" is not empty. Confirmed to delete it? [No]|Yes: yes Deleting "tests\Leeds\" ... Done.