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 .shp.zip file of Rutland as an example >>> subrgn_name = 'london' >>> file_format = ".pbf" >>> dat_dir = "tests\osm_data" >>> gfr.downloader.download_osm_data(subrgn_name, file_format, dat_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_path = gfr.data_paths[0] >>> os.path.relpath(london_pbf_path) 'tests\osm_data\greater-london\greater-london-latest.osm.pbf' >>> lyr_idx_names = gfr.get_pbf_layer_names(london_pbf_path) >>> 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(dat_dir, verbose=True) To delete the directory "tests\osm_data\" (Not empty) ? [No]|Yes: yes Deleting "tests\osm_data\" ... Done.