GeofabrikDownloader.make_sub_download_dir

GeofabrikDownloader.make_sub_download_dir(subregion_name, osm_file_format, download_dir=None, mkdir=False)

Make a default directory for downloading data of a geographic region’s subregions.

This is particularly useful when data of a geographic region and requested file format is unavailable.

Parameters
  • subregion_name (str) – name of a geographic region available on Geofabrik free download server

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

  • download_dir (str or None) – directory for saving the downloaded file(s); if None (default), the default directory created by the package

  • mkdir (bool) – whether to create a directory, defaults to False

Returns

default download directory if the requested data file is not available

Return type

str

Example:

>>> import os
>>> from pydriosm.downloader import GeofabrikDownloader

>>> geofabrik_downloader = GeofabrikDownloader()

>>> region_name = 'london'
>>> file_format = ".pbf"

>>> # Default download directory (if the requested data file is not available)
>>> dwnld_dir = geofabrik_downloader.make_sub_download_dir(region_name, file_format)

>>> print(os.path.relpath(dwnld_dir))
osm_geofabrik\Europe\Great Britain\England\Greater London\greater-lond...

>>> region_name = 'britain'
>>> file_format = ".shp"

>>> # Default download directory (if the requested data file is not available)
>>> dwnld_dir = geofabrik_downloader.make_sub_download_dir(region_name, file_format,
...                                                        download_dir="tests")

>>> print(os.path.relpath(dwnld_dir))
tests\Great Britain\great-britain-shp-zip