Basic Usage
Inspecting a PBF file
Get an overview of any PBF file - block breakdown, element counts, ordering analysis:
pbfhogg inspect denmark.osm.pbfCheck if a PBF has blob-level indexdata (exit code 0 = indexed, 1 = not):
pbfhogg inspect --indexed denmark.osm.pbfCount tag keys, then the values of one key:
pbfhogg inspect tags denmark.osm.pbf
pbfhogg inspect tags denmark.osm.pbf 'highway=*'For extended analysis (timestamp range, data bbox, metadata coverage):
pbfhogg inspect --extended denmark.osm.pbfGenerating indexdata
Many commands are faster with blob-level indexdata. Generate an indexed PBF with cat:
pbfhogg cat denmark-raw.osm.pbf -o denmark.osm.pbfThis passthrough path adds indexdata without re-compressing blobs, with minimal memory, so it suits planet-scale files; see Performance for measurements. A blob that already carries indexdata is copied as it is; cat --reindex rebuilds indexdata from the payload when it is suspect.
Extracting a region
Extract by bounding box:
pbfhogg extract denmark.osm.pbf -o copenhagen.osm.pbf -b 12.4,55.6,12.7,55.8The default strategy is complete-ways (two passes, all way nodes included, and every relation containing an included relation). The box edges are inclusive. For faster extraction with possible dangling refs:
pbfhogg extract denmark.osm.pbf -o copenhagen.osm.pbf -b 12.4,55.6,12.7,55.8 --simpleFor complete multipolygon and boundary relations (see extract for exactly what each strategy includes):
pbfhogg extract denmark.osm.pbf -o copenhagen.osm.pbf -b 12.4,55.6,12.7,55.8 --smartExtract by GeoJSON polygon:
pbfhogg extract denmark.osm.pbf -o region.osm.pbf -p boundary.geojsonApplying a daily diff
Apply an OSC change file to a sorted PBF:
pbfhogg apply-changes denmark.osm.pbf changes.osc.gz -o updated.osm.pbfTo keep a file with inline way-node coordinates (LocationsOnWays) current without re-running add-locations-to-ways after each update, build it once from a sorted, indexed PBF with untagged nodes kept (add-locations-to-ways keeps its order and indexdata), then apply each diff with --locations-on-ways:
pbfhogg add-locations-to-ways denmark.osm.pbf -o denmark-low.osm.pbf --keep-untagged-nodes
pbfhogg apply-changes denmark-low.osm.pbf changes.osc.gz -o updated.osm.pbf --locations-on-waysEach way's inline coordinates get the new position of every node the diff moves, whether the diff touches the way or not. The kept untagged nodes are what makes this work: a way the diff changes takes the coordinates of its unchanged nodes from the base's node records, and a default add-locations-to-ways output, which drops untagged nodes, lacks many of them, so the update can fail on an ordinary daily diff.
Filtering by tags
Filter elements by tag expressions:
pbfhogg tags-filter denmark.osm.pbf -o highways.osm.pbf "highway=primary" "highway=secondary"By default, matched relations pull in their member ways, nodes, and nested relations transitively. For direct matches only (faster, single pass):
pbfhogg tags-filter denmark.osm.pbf -o restaurants.osm.pbf -R "amenity=restaurant"Sorting
Sort a PBF into standard order (nodes, ways, relations by ID):
pbfhogg sort unsorted.osm.pbf -o sorted.osm.pbfExtracting elements by ID
pbfhogg getid denmark.osm.pbf -o subset.osm.pbf n123 w456 r789Remove specific elements (keep everything else):
pbfhogg getid denmark.osm.pbf -o filtered.osm.pbf --invert n123 w456The --force flag
Many commands refuse an input without indexdata. On those that offer it, --force runs the slower fallback instead:
pbfhogg sort raw-input.osm.pbf -o sorted.osm.pbf --forceWhich commands refuse, and where --force is not the escape, is in Indexdata. The recommended workflow is to generate an indexed PBF once with pbfhogg cat, then use it for all subsequent operations.
Outputs
Commands that write a file take -o. An existing output is refused unless -O, --overwrite is given, and a failed run never leaves a partial file under the output name:
pbfhogg sort input.osm.pbf -o sorted.osm.pbf --overwriteEvery flag, and the full output contract, is in the CLI reference; its Common flags and Output files sections cover what most write commands share.