GeofabrikDownloader.get_subregion_table

classmethod GeofabrikDownloader.get_subregion_table(url, verbose=False, raise_error=False)[source]

Get download information of all geographic (sub)regions on a web page.

Parameters:
  • url (str) – URL of a subregion’s web page

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

  • raise_error (bool) – Whether to raise the provided exception; if raise_error=False (default), the error will be suppressed.

Returns:

download information of all available subregions on the given url

Return type:

pandas.DataFrame | None

Examples:

>>> from pydriosm.downloader import GeofabrikDownloader
>>> gfd = GeofabrikDownloader()

>>> # Download information on the homepage
>>> subregion_table = gfd.get_subregion_table(url=gfd.URL)
>>> subregion_table
               subregion  ... .osm.bz2
0                 Africa  ...     None
1             Antarctica  ...     None
2                   Asia  ...     None
3  Australia and Oceania  ...     None
4        Central America  ...     None
5                 Europe  ...     None
6          North America  ...     None
7          South America  ...     None
[8 rows x 7 columns]
>>> subregion_table.columns.to_list()
['subregion',
 'subregion-url',
 '.osm.pbf',
 '.osm.pbf-size',
 '.gpkg.zip',
 '.shp.zip',
 '.osm.bz2']

>>> # Download information about 'Great Britain'
>>> url = 'https://download.geofabrik.de/europe/united-kingdom.html'
>>> subregion_table = gfd.get_subregion_table(url)
>>> subregion_table
          subregion  ... .osm.bz2
0           Bermuda  ...     None
1           England  ...     None
2  Falkland Islands  ...     None
3          Scotland  ...     None
4             Wales  ...     None
[5 rows x 7 columns]

>>> # Download information about 'Antarctica'
>>> url = 'https://download.geofabrik.de/antarctica.html'
>>> subregion_table = gfd.get_subregion_table(url, verbose=True)
Compiling a subregion list of "Antarctica" ... Failed.
  No data is available for 'Antarctica'.
>>> subregion_table is None
True
>>> # To get more information about the above failure, set `verbose=2`
>>> subregion_table = gfd.get_subregion_table(url, verbose=2)
Compiling a subregion list of "Antarctica" ... Failed.
  No data is available for 'Antarctica'.
  Errors: 'NoneType' object has no attribute 'empty'.
>>> subregion_table is None
True