PBFReadParse.get_pbf_layer_names
- classmethod PBFReadParse.get_pbf_layer_names(pbf_pathname, verbose=False)[source]
Get names (and indices) of all available layers in a PBF data file.
- Parameters:
pbf_pathname (str | os.PathLike[str]) – path to a PBF data file
verbose (bool | int) – whether to print relevant information in console, defaults to
False
- Returns:
indices and names of each layer of the PBF data file
- Return type:
dict
Examples:
>>> from pydriosm.reader import PBFReadParse >>> from pydriosm.downloader import GeofabrikDownloader >>> from pyhelpers.dirs import delete_dir >>> import os >>> # Download the PBF data file of London as an example >>> subrgn_name = 'london' >>> file_format = ".pbf" >>> dwnld_dir = "tests\osm_data" >>> gfd = GeofabrikDownloader() >>> gfd.download_osm_data(subrgn_name, file_format, dwnld_dir, verbose=True) To download .osm.pbf data of the following geographic (sub)region(s): Greater London ? [No]|Yes: yes Downloading "greater-london-latest.osm.pbf" to "tests\osm_data\greater-london\" ... Done. >>> london_pbf_pathname = gfd.data_paths[0] >>> os.path.relpath(london_pbf_pathname) 'tests\osm_data\greater-london\greater-london-latest.osm.pbf' >>> # Get indices and names of all layers in the downloaded PBF data file >>> pbf_layer_idx_names = PBFReadParse.get_pbf_layer_names(london_pbf_pathname) >>> type(pbf_layer_idx_names) dict >>> pbf_layer_idx_names {0: 'points', 1: 'lines', 2: 'multilinestrings', 3: 'multipolygons', 4: 'other_relations'} >>> # Delete the download directory (and the downloaded PBF data file) >>> delete_dir(gfd.download_dir, verbose=True) To delete the directory "tests\osm_data\" (Not empty) ? [No]|Yes: yes Deleting "tests\osm_data\" ... Done.