GeofabrikDownloader.specify_sub_download_dir¶
- GeofabrikDownloader.specify_sub_download_dir(subregion_name, osm_file_format, download_dir=None, **kwargs)[source]¶
Specify a directory for downloading data of all subregions of a geographic (sub)region.
This is useful when the specified format of the data of a geographic (sub)region is not available at Geofabrik free download server.
- Parameters:
subregion_name (str) – name of a (sub)region available on Geofabrik 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; whendownload_dir=None, it refers tocdd_geofabrik().cdd_geofabrik()kwargs – [optional] parameters of pyhelpers.dirs.cd(), including
mkdir``(default: ``False)
- Returns:
pathname of a download directory for downloading data of all subregions of the specified (sub)region and format
- Return type:
str
Examples:
>>> from pydriosm.downloader import GeofabrikDownloader >>> import os >>> gfd = GeofabrikDownloader() >>> subregion_name = 'london' >>> osm_file_format = ".pbf" >>> # Default download directory (if the requested data file is not available) >>> download_pathname = gfd.specify_sub_download_dir(subregion_name, osm_file_format) >>> os.path.dirname(os.path.relpath(download_pathname)) 'osm_data\geofabrik\europe\united-kingdom\england\greater-london' >>> # When a download directory is specified >>> subregion_name = 'britain' >>> osm_file_format = ".shp" >>> download_dir = "tests/osm_data" >>> download_pathname = gfd.specify_sub_download_dir( ... subregion_name, osm_file_format, download_dir) >>> os.path.relpath(download_pathname) 'tests\osm_data\great-britain-shp-zip' >>> gfd_ = GeofabrikDownloader(download_dir=download_dir) >>> download_pathname = gfd_.specify_sub_download_dir(subregion_name, osm_file_format) >>> os.path.relpath(download_pathname) 'tests\osm_data\europe\great-britain\great-britain-shp-zip'