pyrosm.OSM.get_graph

Contents

pyrosm.OSM.get_graph#

OSM.get_graph(network_type='walking', graph_type='igraph', direction='oneway', force_bidirectional=False, retain_all=False, osmnx_compatible=True, pandana_weights=['length'], simplify=True, simplify_kwargs=None, extra_attributes=None, custom_filter=None, filter_type=None, tags_to_keep=None, timestamp=None)#

Read the street network of network_type as a routable graph: the graph of OSM.to_graph(*osm.get_network(network_type, nodes=True), graph_type).

With the out-of-core engine the simplified graph is built straight from the ways and nodes read from the file: the tables of every street segment and of every node that get_network(nodes=True) returns are not built, so the read takes less memory. With simplify=False, the in-memory engine or a history read, the tables are read with get_network and exported with to_graph.

The read and the export show one progress as the progress of this object says: a bar “Building the graph of <file>” from 0 to 100 % with the current step in its label, or progress(done, 100) calls.

Parameters:
  • network_type – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • extra_attributes – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • custom_filter – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • filter_type – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • tags_to_keep – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • timestamp – As in get_network(). With tags_to_keep, the tags the graph is built from are read too: those of its edges’ directions (oneway and junction, and oneway:bicycle for cycling) and, with simplify, the edge_attrs_differ tags (by default maxspeed and highway), so the graph is the same and only carries fewer attributes.

  • graph_type – As in to_graph().

  • direction – As in to_graph().

  • force_bidirectional – As in to_graph().

  • retain_all – As in to_graph().

  • osmnx_compatible – As in to_graph().

  • pandana_weights – As in to_graph().

  • simplify – As in to_graph().

  • simplify_kwargs – As in to_graph().

Returns:

  • igraph.Graph, networkx.MultiDiGraph, pandarm.Network or pandana.Network, or

  • None when the network is empty.