Skip to content

hscherl/imposm-parser

This branch is 5 commits ahead of, 5 commits behind omniscale/imposm-parser:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d6f033a · Mar 8, 2016

History

68 Commits
Sep 13, 2013
Mar 8, 2016
Jun 13, 2012
Feb 21, 2011
Jul 21, 2011
Oct 31, 2014
Feb 22, 2011
Jun 13, 2012
Dec 10, 2012
Feb 21, 2011
Dec 10, 2012
Mar 8, 2016
Feb 22, 2011

Repository files navigation

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.

About

Python parser for OpenStreetMap data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 73.8%
  • Python 22.4%
  • Protocol Buffer 3.8%