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.

  • 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; when download_dir=None, it refers to the method cdd()

  • kwargs – [optional] parameters of, including mkdir``(default: ``False)


pathname of a download directory for downloading data of all subregions of the specified (sub)region and format

Return type:



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

>>> gfd = GeofabrikDownloader()

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

>>> # Default download directory (if the requested data file is not available)
>>> dwnld_dir = gfd.specify_sub_download_dir(subrgn_name, file_format)
>>> os.path.dirname(os.path.relpath(dwnld_dir))

>>> # When a download directory is specified
>>> dwnld_dir = "tests\osm_data"

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

>>> dwnld_pathname = gfd.specify_sub_download_dir(subrgn_name, file_format, dwnld_dir)
>>> os.path.relpath(dwnld_pathname)

>>> gfd_ = GeofabrikDownloader(download_dir=dwnld_dir)
>>> dwnld_pathname_ = gfd_.specify_sub_download_dir(subrgn_name, file_format)
>>> os.path.relpath(dwnld_pathname_)