Skip to content
Python parser for OpenStreetMap data
Find file
Pull request Compare This branch is 7 commits behind omniscale:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
doc
imposm
.gitignore
.hgignore
.hgtags
CHANGES
LICENSE
MANIFEST.in
README.rst
osm.proto
release.py
setup.py
tox.ini

README.rst

imposm.parser - OpenStreetMap XML/PBF parser for Python

imposm.parser is a Python library that parses OpenStreetMap data in XML and PBF format.

It has a simple API and it is fast and easy to use. It also works across multiple CPU/cores for extra speed.

It is developed and supported by Omniscale and released under the Apache Software License 2.0.

Example

Here is an example that parses an OSM file and counts all ways that are tagged as a highway.

from imposm.parser import OSMParser

# simple class that handles the parsed OSM data.
class HighwayCounter(object):
    highways = 0

    def ways(self, ways):
        # callback method for ways
        for osmid, tags, refs in ways:
            if 'highway' in tags:
              self.highways += 1

# instantiate counter and parser and start parsing
counter = HighwayCounter()
p = OSMParser(concurrency=4, ways_callback=counter.ways)
p.parse('germany.osm.pbf')

# done
print counter.highways

Source and issue tracker

Source code and issue tracker are available at https://github.com/omniscale/imposm-parser.

Something went wrong with that request. Please try again.