Code reference for Transit + OSMnx¶
final_project.network¶
final_project.cartography¶
final_project.routing¶
routing.py
Home of the RoutingMixin. Provides utilities for routing, finding a graph’s nearest nodes, and shortests paths between them.
-
class
final_project.routing.RoutingMixin¶ RoutingMixin to be used by Network class for additional Routing functionality: class Network(RoutingMixin). Thus references to self are references to a Network.
-
get_route_length(route)¶ Uses a Network’s graph to find details about a route
- Parameters
route (List[int or str]) – List of node id’s representing a route
- Returns
length (float)
-
get_shortest_pair(origin, dest, k=3)¶ Find the route that is shortest between the k-nearest neighbors of two points
- Parameters
origin (tuple(lat, lon)) – Starting point. make sure to use (Y, X) coordinates
dest (tuple(lat, lon)) – Ending point. make sure to use (Y, X) coordinates
k (int) – number of nearest nodes to try
Returns:
-
nearest_k_nodes(X, Y, k=1, return_dist=False)¶ based on osmnx.distance.nearest_nodes, but modified to work for k-nearest nodes
Find the k nearest node(s) to some point(s) based on a Graph (self)
- Parameters
self (final_project.network) – Network in which to find nearest nodes
X (float or numpy.array) – points’ x or longitude coordinates, in same CRS/units as graph and
no nulls (containing) –
Y (float or numpy.array) – points’ y or latitude coordinates, in same CRS/units as graph and
no nulls –
k (int) – number of nearest nodes to return
return_dist (bool) – optionally also return distance between points and nearest nodes
- Returns
nn or (nn, dist) nearest node IDs or optionally a tuple where dist contains distances between the points and their nearest nodes
-
-
final_project.routing.is_projected(crs)¶ borrowed from osmnx