Osmread
Simple library for reading OpenStreetMap XML and PBF data files
Install / Use
/learn @dezhin/OsmreadREADME
Osmread
Osmread is a simple library for reading OpenStreetMap data files in Python. It supports XML and PBF file formats as inputs. It is not designed for fast processing of big planet dumps but can be used for simple processing of smaller files such as regional extracts.
If you need fast processing of large files look at imposm.parser library.
Installation
Simply run setup.py or use pip or easy_install.
$ python setup.py install
Example usage
from osmread import parse_file, Way
highway_count = 0
for entity in parse_file('foo.osm.bz2'):
if isinstance(entity, Way) and 'highway' in entity.tags:
highway_count += 1
print("%d highways found" % highway_count)
All Node, Way and Relation instances have id, version, changeset,
timestamp, uid and tags attributes. Node coordinates stored in lon and
lat. Way nodes stored in nodes, relation members in members.
Relation members are array of tuples (role, class, id), where class is
Node, Way or Relation.
PBF implementation note
This library uses very slow protobuf implementation - pure python protobuf library. As a result parsing PBF files is slower than XML. This may change in future versions.
Related Skills
node-connect
354.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
