Here's a template that can be used to write a script that uses my adaption of the parser:
import OSMpbfParser def callback_node(node): do_something_with(node) def callback_way(way): do_something_with(way) def callback_relation(relation): do_something_with(relation) OSMpbfParser.go( 'the-file-to-be-parsed.pbf', callback_node, callback_way, callback_relation)
Each of the callback functions has exactly one parameter that corresponds to the classes
OSMRelation(see the source at github).
Installing google's protocol buffersTo parse pbf files, google's protocol buffers are needed. The can be optained from code.google.com/p/protobuf/downloads/list.
For Windows, I downloaded protoc-2.5.0-win32.zip which contains one file:
protoc.exe. After extracting this file, the environment variable
PATHshould be changed so that it points to the directory with
protoc.exe. For the python installation, the full source protobuf-2.5.0.tar.bz2 is also needed. After extracting them,
cdinto the python directory and execute:
cd protobuf-2.5.0\protobuf-2.5.0\python python setup.py build python setup.py test python setup.py install
Source code on githubconvert pbf files to xml