GeofabrikDownloader.get_subregions

GeofabrikDownloader.get_subregions(*subregion_name, deep=False)[source]

Retrieve names of all subregions (if any) of the given geographic (sub)region(s).

The returned result is based on the region-subregion tier structured by the method get_region_subregion_tier().

See also [RNS-1].

Parameters:
  • subregion_name (str | None) – name of a (sub)region, or names of (sub)regions, available on Geofabrik free download server

  • deep (bool) – whether to get subregion names of the subregions, defaults to False

Returns:

name(s) of subregion(s) of the given geographic (sub)region or (sub)regions; when subregion_name=None, it returns all (sub)regions that have subregions

Return type:

list

Examples:

>>> from pydriosm.downloader import GeofabrikDownloader

>>> gfd = GeofabrikDownloader()

>>> # Names of all subregions
>>> all_subrgn_names = gfd.get_subregions()
>>> type(all_subrgn_names)
list

>>> # Names of all subregions of England and North America
>>> e_na_subrgn_names = gfd.get_subregions('england', 'n america')
>>> type(e_na_subrgn_names)
list

>>> # Names of all subregions of North America
>>> na_subrgn_names = gfd.get_subregions('n america', deep=True)
>>> type(na_subrgn_names)
list

>>> # Names of subregions of Great Britain
>>> gb_subrgn_names = gfd.get_subregions('britain')
>>> len(gb_subrgn_names) == 3
True

>>> # Names of all subregions of Great Britain's subregions
>>> gb_subrgn_names_ = gfd.get_subregions('britain', deep=True)
>>> len(gb_subrgn_names_) >= len(gb_subrgn_names)
True