Skip to main content

Low-level interface to OpenStreetMap protocol buffer files.

Project description

esy.osm.pbf is a low-level Python library to interact with OpenStreetMap data files in the Protocol Buffers language.

The OpenStreetMap PBF format defines three primary data types:

  • Node: An annotated point on the earth.

  • Way: An list of Node items forming a path or polygon.

  • Relation: A set of related entries.

This library uses Google’s protobuf Python implementation to decode binary data into native Python objects and offers a convenient interface to iterate over all elements found in a .pbf data file.


What it provides:

  • A pythonic way to work with .pbf data file entries.

  • Conversion of lowlevel Protocol Buffer objects to Python objects like dictionaries and lists.

  • An easy way to filter and process OpenStreetMap data with Python.

What it doesn’t provide:

  • A mechanism to spatially query OpenStreetMap entries.

  • Visualization of OpenStreetMap data.


esy.osm.pbf depends on a Python version of 3.5 or above as well as on the Google Protocol Buffers. Use pip to install esy.osm.pbf:

$ pip install esy-osm-pbf


The following example selects some entries from the Andorra .pbf provided by geofabrik. The entries contained in these files can be accessed using esy.osm.pbf.File objects.

Openstreetmap defines parks by a tag leisure with a value of park. Filter entries accordingly and store matching ones in a list parks:

>>> import esy.osm.pbf
>>> osm = esy.osm.pbf.File('test/andorra.osm.pbf')
>>> parks = [entry for entry in osm if entry.tags.get('leisure') == 'park']
>>> len(parks)

In this copy of the Andorra .pbf, there seem to be at least 24 parks. Lets select all with a name and show the first three of those:

>>> [entry.tags['name'] for entry in parks if 'name' in entry.tags][:3]
['Jardins de Juberri', 'Parc Central', 'Plaça Guillemó']


esy.osm.pbf is licensed under the GNU General Public License version 3.0.

The Team

esy.osm.pbf is developed at the DLR Institute of Networked Energy Systems in the departement for Energy Systems Analysis (ESY).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esy-osm-pbf-0.0.1.tar.gz (11.2 kB view hashes)

Uploaded source

Built Distribution

esy_osm_pbf-0.0.1-py3-none-any.whl (10.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page