I'm trying to extract a Road Network from a large set of GPS point data gathered from vehicles.
I plan on representing the final network in terms of a NetworkX graph of G(V,E)
I have implemented step 1 which is to extract a list of "Trajectories" from the data (grouping the data into short logical trips) and these trajectories can be pretty nicely plotted, but obviously many of them overlap. A graph must be constructed where the overlaps collapse to form final paths.
Building the final network graph will be done in a incremental approach, starting with a completely empty graph as follows:
For each trip in trajectories:
for each point in trip:
find the (spatially) closest graph node to the given point
if distance(closest_node, candidate_node) < node_threshold:
Obviously I need a fast indexed way to do spatial queries on the graph if this is going to be feasible.
Ideally I planned on storing custom Python objects at each node. The objects would be as follows:
def __init__(self, lat, lon):
self.latitude = lat
self.longitude = lon
and I was planning on adding nodes in the form:
Im struggling to find much examples on doing this type of thing. Is there a built in way to efficiently query the NetworkX graph for nodes spatially close to some candidate node?
Or would a better approach be to keep an additional queryable structure to find node references that are spatially close to the candidate node and then use that reference to operate on the graph?