GeofabrikDownloader.get_subregion_download_url

GeofabrikDownloader.get_subregion_download_url(subregion_name, osm_file_format, update=False, verbose=False, raise_error=True)[source]

Get a download URL of a geographic (sub)region.

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

  • update (bool) – whether to (check on and) update the prepacked data, defaults to False

  • verbose (bool | int) – whether to print relevant information in console, defaults to False

  • raise_error (bool) – (if the input fails to match a valid name) whether to raise an pydriosm.errors.InvalidSubregionNameError or InvalidFileFormatError; defaults to True

Returns:

name and URL of the subregion

Return type:

tuple

Examples:

>>> from pydriosm.downloader import GeofabrikDownloader
>>> gfd = GeofabrikDownloader()
>>> subregion_name = 'England'
>>> osm_file_format = ".pbf"
>>> subregion_name_, download_url = gfd.get_subregion_download_url(
...     subregion_name, osm_file_format)
>>> subregion_name_  # The name of the subregion on the free downloader server
'England'
>>> download_url  # The URL of the PBF data file
'https://download.geofabrik.de/europe/united-kingdom/england-latest.osm.pbf'
>>> subregion_name = 'britain'
>>> osm_file_format = ".geopackage"  # Or, osm_file_format = ".gpkg"
>>> subregion_name_, download_url = gfd.get_subregion_download_url(
...     subregion_name, osm_file_format)
>>> subregion_name_
'Great Britain'
>>> download_url is None  # The URL of the shapefile for Great Britain is not available
True