osmium - Processing OSM files

Osmium processes files by reading data from a file and applying them to a processing chain. Pyosmium offers a simplified wrapper to this interface with the SimpleHandler class from which an OSM file processor can easily be derived.

For more fine grained control of the processing chain, the more basic functions and processors are exported as well in this module.

Simple Handlers

class osmium.SimpleHandler

A handler implements custom processing of OSM data. For each data type a callback can be implemented where the object is processed. Note that all objects that are handed into the handler are only readable and are only valid until the end of the callback is reached. Any data that should be retained must be copied into other data structures.

apply_file((SimpleHandler)self, (str)filename[, (bool)locations=False[, (str)idx='sparse_mem_array']]) → None :

Apply the handler to the given file. If locations is true, then a location handler will be applied before, which saves the node positions. In that case, the type of this position index can be further selected in idx. If an area callback is implemented, then the file will be scanned twice and a location handler and a handler for assembling multipolygones and areas from ways will be executed.

area((SimpleHandler)self, (Area)area) → None :

Handler called for area objects.

area( (SimpleHandler)self, (Area)area) -> None

changeset((SimpleHandler)self, (Changeset)changeset) → None :

Handler called for changeset objects.

changeset( (SimpleHandler)self, (Changeset)changeset) -> None

node((SimpleHandler)self, (Node)node) → None :

Handler called for node objects.

node( (SimpleHandler)self, (Node)node) -> None

relation((SimpleHandler)self, (Relation)relation) → None :

Handler called for relation objects.

relation( (SimpleHandler)self, (Relation)relation) -> None

way((SimpleHandler)self, (Way)way) → None :

Handler called for way objects. If the geometry of the way is needed then locations must be set to true when calling apply_file.

way( (SimpleHandler)self, (Way)way) -> None

Low-level Functions and Classes

osmium.apply((Reader)arg1, (SimpleHandler)arg2) → None :

Apply a chain of handlers.

apply( (Reader)arg1, (NodeLocationsForWays)arg2) -> None

apply( (Reader)arg1, (NodeLocationsForWays)arg2, (SimpleHandler)arg3) -> None