BBBikeReader.get_pbf_layer_names

BBBikeReader.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 BBBikeReader
>>> from pyhelpers.dirs import delete_dir
>>> import os
>>> bbr = BBBikeReader()
>>> # Download the PBF data of Birmingham as an example
>>> subregion_name = 'birmingham'
>>> osm_file_format = ".pbf"
>>> data_dir = "tests/osm_data"
>>> # Download the PBF data of Birmingham to "./tests/osm_data/"
>>> bbr.downloader.download_data(
...     subregion_name, osm_file_format, data_dir, verbose=True)
Proceed to download data in the format '.pbf' for the following geographic (sub)reg...
  "Birmingham"
  to "./tests/osm_data/birmingham/"
? [No]|Yes: yes
Downloading "Birmingham.osm.pbf" 100%|██████████| 55.8M/55.8M | 15.3MB/s | ET...
  Saving "Birmingham.osm.pbf" to "./tests/osm_data/birmingham/" ... Done.
>>> path_to_pbf = bbr.data_paths[0]
>>> os.path.relpath(path_to_pbf)
'tests\osm_data\birmingham\Birmingham.osm.pbf'
>>> lyr_idx_names = bbr.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.