observe

Street continuity analysis. Identifies continuous street sequences — chains of connected street segments that share the same name, route number, or highway classification — and computes continuity metrics from NetworkX graphs. For network centrality methods, see the networks module.

ContinuityEntry

State management for an individual street continuity entry. This corresponds to an individual street name, route name or number, or highway type.

ContinuityEntry

ContinuityEntry
(
entry_name : str
)

Instances a continuity entry.

generate_key

@staticmethod
generate_key
(
start_nd_key : str
end_nd_key : str
edge_idx : int
)

Generate a unique key given uncertainty of start and end node order.

add_edge

add_edge
(
self
length : float
start_nd_key : str
end_nd_key : str
edge_idx : int
)

Adds edge details to a continuity entry.

StreetContinuityReport

State management for a collection of street continuity metrics. Each key in the entries attribute corresponds to a ContinuityEntry.

StreetContinuityReport

StreetContinuityReport
(
method : str
)

Instance a street continuity report.

scaffold_entry

scaffold_entry
(
self
entry_name : str
)

Adds a new continuity entry to the report’s entries.

report_by_count

report_by_count
(
self
n_items : int = 10
)

Print a report sorted by entry counts.

report_by_length

report_by_length
(
self
n_items : int = 10
)

Print a report sorted by entry lengths.

street_continuity

street_continuity
(
nx_multigraph : networkx.classes.multigraph.MultiGraph
method : str | tuple[str, str]
)->[ MultiGraph StreetContinuityReport ]

Compute the street continuity for a given graph. This requires a graph with names, routes, or highways edge keys corresponding to the selected method parameter. These keys are available if importing an OSM network with osm_graph_from_poly or if importing OS Open Roads data with nx_from_open_roads.

Parameters

nx_multigraph
MultiGraph

A networkX MultiGraph with a crs attribute denoting a projected coordinate system, containing x and y node attributes, and geom edge attributes containing LineString geoms. Edges should contain “names”, “routes”, or “highways” keys corresponding to the specified method parameter.

method
str

The type of continuity metric to compute, where available options are “names”, “routes”, or “highways”.

Returns

MultiGraph

A copy of the input networkX MultiGraph with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in ‘length’ and ‘count’ forms for the specified method, with keys formatted according to f"{method}_cont_by_{form}". For example, when computing “names” continuity, the names_cont_by_count and names_cont_by_length keys will be added to the returned networkX MultiGraph.

StreetContinuityReport

An instance of StreetContinuityReport containing the computed state for the selected method.

Notes

For worked examples, see the Street Continuity from OSM recipe.

hybrid_street_continuity

hybrid_street_continuity
(
nx_multigraph : networkx.classes.multigraph.MultiGraph
)->[ MultiGraph StreetContinuityReport ]

Compute the street continuity for a given graph by combining route and name-based continuity. Where a named route (e.g. a bus route or highway number) runs along streets with consistent names, the two sources of continuity information are merged to produce a more complete picture of coherent street sequences.

Parameters

nx_multigraph
MultiGraph

A networkX MultiGraph with a crs attribute denoting a projected coordinate system, containing x and y node attributes, and geom edge attributes containing LineString geoms. Edges should contain “names”, “routes”, or “highways” keys corresponding to the specified method parameter.

Returns

MultiGraph

A copy of the input networkX MultiGraph with new edge keys corresponding to the calculated route continuity metric. The metrics will be stored in ‘hybrid_cont_by_length’ and ‘hybrid_cont_by_count’ keys.

StreetContinuityReport

An instance of StreetContinuityReport containing the computed state for the “hybrid” method.