osm_utils

osm.osm_utils

Utility functions for OSM files.

Functions

Name Description
filter_osm Filter an osm.pbf file to a bbox. Relies on homebrew with osmosis.

filter_osm

osm.osm_utils.filter_osm(pbf_pth=here('tests/data/newport-2023-06-13.osm.pbf'), out_pth=here('outputs/osm/filtered.osm.pbf'), bbox=[-3.01, 51.58, -2.99, 51.59], tag_filter=True, install_osmosis=False)

Filter an osm.pbf file to a bbox. Relies on homebrew with osmosis.

Parameters

Name Type Description Default
pbf_pth Union[str, pathlib.PosixPath] Path to the open street map pbf to be filtered. Defaults to here(“tests/data/newport-2023-06-13.osm.pbf”). here('tests/data/newport-2023-06-13.osm.pbf')
out_pth Union[str, pathlib.PosixPath] Path to write to. Defaults to here(“outputs/osm/filtered.osm.pbf”). here('outputs/osm/filtered.osm.pbf')
bbox list Bounding box used to perform the filter, in left, bottom, right top order. Defaults to [-3.01, 51.58, -2.99, 51.59]. [-3.01, 51.58, -2.99, 51.59]
tag_filter bool Should non-highway ways be filtered? Excludes buildings, waterway, landuse & natural. Defaults to True. True
install_osmosis bool Should brew be used to install osmosis if not found. Defaults to False. False

Raises

Type Description
Exception: Subprocess error. Exception: Osmosis not found. Will not raise if install_osmosis=True.

Returns

Type Description
None