GeofabrikReader.get_pbf_layer_names

GeofabrikReader.get_pbf_layer_names(subregion_name, data_dir=None)[source]

Get indices and names of all layers in the PBF data file of a given (sub)region.

Parameters:
  • subregion_name (str) – name of a geographic (sub)region (case-insensitive) that is available on Geofabrik free download server

  • data_dir

Returns:

indices and names of each layer of the PBF data file

Return type:

dict

Examples:

>>> from pydriosm.reader import GeofabrikReader
>>> from pyhelpers.dirs import delete_dir
>>> import os
>>> gfr = GeofabrikReader()
>>> # Download the PBF data of Rutland as an example
>>> subregion_name = 'rutland'
>>> osm_file_format = ".pbf"
>>> data_dir = "tests/osm_data"
>>> # Download the PBF data of Rutland to "./tests/osm_data/"
>>> gfr.downloader.download_data(
...     subregion_name, osm_file_format, data_dir, verbose=True)
To download data in the format '.osm.pbf' for the following geographic (sub)region(s):
    "Rutland"
  to "./tests/osm_data/rutland/"
? [No]|Yes: yes
Downloading "rutland-latest.osm.pbf" 100%|██████████| 1.83M/1.83M | 1.00MB/s ...
    Saving "rutland-latest.osm.pbf" to "./tests/osm_data/rutland/" ... Done.
>>> path_to_pbf = gfr.data_paths[0]
>>> os.path.relpath(path_to_pbf)
'tests\osm_data\rutland\rutland-latest.osm.pbf'
>>> lyr_idx_names = gfr.get_pbf_layer_names(subregion_name)
>>> lyr_idx_names
{0: 'points',
 1: 'lines',
 2: 'multilinestrings',
 3: 'multipolygons',
 4: 'other_relations'}
>>> # Delete the example data and the test data directory
>>> delete_dir(data_dir, verbose=True)
To delete the directory "./tests/osm_data/" (Not empty)
? [No]|Yes: yes
Deleting "./tests/osm_data/" ... Done.