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.
Features
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.
Installation
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
Example
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) 24
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ó']
License
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for esy_osm_pbf-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc3d46567009e2607a04b0f5b3f238d476fe93aea01d282d9981bc7329751a87 |
|
MD5 | c540bea9b2dc3306d07cfbe1e11952db |
|
BLAKE2b-256 | 4436f49f2f39618aefb9cd5687727eca79bdf21ef553b3dfbba01df5892fc320 |