Introduction
The PBF format is the compact binary form of OpenStreetMap
data, the free map of the world built by volunteers. The whole planet and regional
extracts are published as .osm.pbf files, which are much smaller and faster
to read than the same data in OpenStreetMap’s XML format (.osm). PBF stands
for Protocolbuffer Binary Format: the data is encoded with
Protocol Buffers.
The file holds OpenStreetMap’s three kinds of element: nodes, points
with a latitude and longitude; ways, ordered lists of nodes that make
roads, rivers and building outlines; and relations, groups of other
elements. Each element carries tags, such as highway=residential.
Structure
The file is a sequence of blocks with no overall header. Each block is:
- a 4-byte big-endian length
- a
BlobHeadermessage of that length, giving the block type,OSMHeaderorOSMData, and the size of the blob - a
Blobmessage holding the block’s data, raw or compressed, usually with zlib
The first block is an OSMHeader with the bounding box and the features a
reader must support. Each OSMData block is a primitive block of up to
8,000 elements. Its strings are kept in one table and referred to by number, and
coordinates and IDs are stored as differences from the previous one, often in the packed
DenseNodes form, which keeps the file small.
Links
Software
- Osmium Tool, which filters, merges and converts OSM files (Windows, macOS, Linux)
- osm2pgsql, which loads OSM data into PostgreSQL
- QGIS, through GDAL’s OSM driver (Windows, macOS, Linux)
Developers
Reference
- PBF Format, the OpenStreetMap wiki