Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

OpenStreetMap PBF Import

1. Overview

In addition to Overture Maps Foundation (OMF) cloud datasets, BAMBAM can build multimodal road networks directly from local OpenStreetMap (.osm.pbf) extracts (such as regional extracts from Geofabrik).

Both the OMF and OSM import pipelines share the same underlying graph construction engine (bambam-network), ensuring identical output file structures and modeling guarantees:

  • Non-Destructive Topological Splitting: OSM ways are split at intersections and simplified to collapse intermediate degree-2 shape nodes while preserving full WKT LineString geometries.
  • Spatial Infrastructure Attachment: OSM nodes tagged with traffic_signals, stop, give_way, or crossing are spatially matched (within 15 meters) to intersection vertices.
  • Modal Filtering & Island Removal: Ways are filtered by highway class and modal access tags into walk/, bike/, and drive/ edge lists, and disconnected network islands smaller than 2 miles are pruned.
  • Drop-In Compatibility: Produces the exact same bambam.toml, vertices-compass.csv.gz, and <mode>/edges-*.gz layout as Overture Maps imports.

2. Setup

1. Import an .osm.pbf File (bambam-osm or bambam_util import-network)

Suppose you have downloaded a regional OpenStreetMap extract (e.g., colorado-latest.osm.pbf) and want to build a BAMBAM network clipped to query/denver_470_buffer.txt.

You can run bambam-osm network (or the unified bambam_util import-network --source osm command) using the standard network filter configuration configuration/bambam-network/bambam-network-config.json:

./rust/target/release/bambam-osm network \
  --pbf-file /path/to/colorado-latest.osm.pbf \
  --configuration-file configuration/bambam-network/bambam-network-config.json \
  --extent-file query/denver_470_buffer.txt \
  --output-directory denver_osm

(Alternatively, using bambam_util import-network:)

./rust/target/release/bambam_util import-network \
  --source osm \
  --input-path /path/to/colorado-latest.osm.pbf \
  --configuration-file configuration/bambam-network/bambam-network-config.json \
  --extent-file query/denver_470_buffer.txt \
  --output-directory denver_osm

2. Run BAMBAM

Because the OSM importer generates the standard bambam.toml and modal subdirectories inside denver_osm/, running BAMBAM is identical to the Overture Maps workflow:

cd denver_osm

../rust/target/release/bambam \
  --config-file bambam.toml \
  --query-file ../query/denver_extent.json

3. What Happens

  1. PBF Parsing & Polygonal Clipping:
    • bambam-osm streams the .osm.pbf binary file, filtering OSM ways and nodes against the highway classes defined in bambam-network-config.json and clipping them to the polygon in query/denver_470_buffer.txt.
  2. Raw Parquet Caching & ID Mapping:
    • Raw OSM node and way tables are saved to denver_osm/raw/nodes.parquet and denver_osm/raw/ways.parquet (allowing fast re-imports via --local-source denver_osm without re-parsing the PBF).
    • Bidirectional mappings between RouteE Compass IDs and OSM Node/Way IDs are written to vertices-mapping.csv.gz and <mode>/edges-mapping.csv.gz.
  3. Graph Serialization & Execution:
    • denver_osm/ is populated with bambam.toml, summary.toml, vertices-compass.csv.gz, and the walk/, bike/, and drive/ subdirectories, which bambam then loads to execute the grid access study and produce result.csv and result.json.