PbfFileReader¶
quackosm.pbf_file_reader.PbfFileReader(
tags_filter=None,
geometry_filter=None,
working_directory="files",
osm_way_polygon_features_config=None,
)
¶
quackosm.pbf_file_reader.PbfFileReader(
tags_filter=None,
geometry_filter=None,
working_directory="files",
osm_way_polygon_features_config=None,
)
PbfFileReader.
PBF(Protocolbuffer Binary Format)[1] file reader is a dedicated *.osm.pbf
files reader
class based on DuckDB[2] and its spatial extension[3].
Handler can filter out OSM features based on tags filter and geometry filter to limit the result.
References
PARAMETER | DESCRIPTION |
---|---|
tags_filter |
A dictionary
specifying which tags to download.
The keys should be OSM tags (e.g.
TYPE:
|
geometry_filter |
Region which can be used to filter only
intersecting OSM objects. Defaults to
TYPE:
|
working_directory |
Directory where to save
the parsed
TYPE:
|
osm_way_polygon_features_config |
Config used to determine which closed way features are polygons. Modifications to this config left are left for experienced OSM users. Defaults to predefined "osm_way_polygon_features.json".
TYPE:
|
Source code in quackosm/pbf_file_reader.py
¶
Bases: NamedTuple
List of parquet files read from the *.osm.pbf
file.
¶
Bases: NamedTuple
Final list of parsed features from the *.osm.pbf
file.
¶
Get features GeoDataFrame from a list of PBF files.
Function parses multiple PBF files and returns a single GeoDataFrame with parsed OSM objects.
PARAMETER | DESCRIPTION |
---|---|
file_paths |
Path or list of paths of
TYPE:
|
explode_tags |
Whether to split tags into columns based on OSM tag keys.
If
TYPE:
|
ignore_cache |
(bool, optional): Whether to ignore precalculated geoparquet files or not. Defaults to False.
TYPE:
|
filter_osm_ids |
(list[str], optional): List of OSM features ids to read from the file.
Have to be in the form of 'node/
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame with OSM features. |
Source code in quackosm/pbf_file_reader.py
convert_pbf_to_gpq(
pbf_path,
result_file_path=None,
explode_tags=None,
ignore_cache=False,
filter_osm_ids=None,
)
¶
convert_pbf_to_gpq(
pbf_path,
result_file_path=None,
explode_tags=None,
ignore_cache=False,
filter_osm_ids=None,
)
Convert PBF file to GeoParquet file.
PARAMETER | DESCRIPTION |
---|---|
pbf_path |
Pbf file to be parsed to GeoParquet.
TYPE:
|
result_file_path |
Where to save
the geoparquet file. If not provided, will be generated based on hashes
from provided tags filter and geometry filter. Defaults to
TYPE:
|
explode_tags |
Whether to split tags into columns based on OSM tag keys.
If
TYPE:
|
ignore_cache |
Whether to ignore precalculated geoparquet files or not. Defaults to False.
TYPE:
|
filter_osm_ids |
(list[str], optional): List of OSM features ids to read from the file.
Have to be in the form of 'node/
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Path
|
Path to the generated GeoParquet file.
TYPE:
|