index - Data Stores

The index submodule provides efficient storage containers for preprocessed OSM data.

Node Location Storage

Node location can be cached in a LocationTable. There are different implementations available which should be choosen according to the size of data and whether or not the cache should be permanent. See the Osmium manual for a detailed explaination. The compiled in types can be listed with the map_types function, new stores can be created with create_map.

osmium.index.map_types() list

Return a list of strings with valid types for the location table.

osmium.index.create_map(map_type: str) osmium.index.LocationTable

Create a new location store. The string parameter takes the type and, where required, additional arguments separated by comma. For example, to create an array cache backed by a file foo.store, the map_type should be dense_file_array,foo.store.

class osmium.index.LocationTable

A map from a node ID to a location object. This implementation works only with positive node IDs.

clear(self: osmium.index.LocationTable) None

Remove all entries from the location table.

get(self: osmium.index.LocationTable, id: int) osmium.osm._osm.Location

Return the location for a given id.

set(self: osmium.index.LocationTable, id: int, loc: osmium.osm._osm.Location) None

Set the location for a given node id.

used_memory(self: osmium.index.LocationTable) int

Return the size (in bytes) currently allocated by this location table.