nxhelpers module

tripsender.nxhelpers.get_closest(A, pt)

A function to get the closest point in a numpy array to a point provided.

Parameters
  • A – (numpy Array)

  • pt – (tuple) Input coordinates that may not exist in the graph nodes

Returns

(tuple) Closest point that exists on the graph nodes.

tripsender.nxhelpers.get_route(A, G, source, target, method='dijkstra', plot=False)

A function to perform routing on the the network from source to target. The source and target points do not have to be on the graph. The function uses the get_closest function to find the closest nodes on the graph and then performs the routing using the routing algorithm specified.

Parameters
  • A – (numpy Array) Array of all nodes in the graph

  • G – (networkX Graph) A networkX Graph object that represents a street network

  • source – (tuple) A coordinate of the source point for routing

  • target – (tuple) A coordinate of the destination point for routing

  • method – (str: Optional)

  • plot – (bool: Optional)

Returns

(list) A list of tuples representing the nodes along the shortest path from source to target

tripsender.nxhelpers.graph_from_gdf(geoms)

A function to generate a networkX Graph object from GeoSeries containing street network geometry.

Parameters

geoms – (GeoPandas GeoSeries) The geometry column of the GeoDataFrame containing the road network.

Returns

(networkX Graph) A networkX Graph object representing the street network