I have three datasets that I have loaded into a geodatabase (spatialite or PostGIS):

  1. A set of GPS points collected from individual trips through urban areas. Points have a unique point id, a group trip id, as well as the usual GPS attributes (speed, accuracy, elevation, timestamp, etc).
  2. A set of points corresponding to junctions in a road network.
  3. A set of polylines corresponding to the road segments connecting junctions. These can be identified as a tuple of junction IDs.

I am trying to relate the GPS points back to routes in a network. Ultimately, from each set of GPS points constituting a trip, I would like to identify an ordered set of junctions from my junctions dataset. (Order, JunctionID)

Initially, I started by creating a modestly sized buffer around my junctions, and then simply intersecting the GPS points, grouping by trip id. This gets surprisingly close to identifying a reasonable set of junctions per trip. However it has a few deficiencies:

  • Where junctions are close together, individual GPS points can be captured multiple times. Some tie-breaking mechanism is needed.
  • Similarly, where the urban canyon effect comes into play, there may be stray points erroneously by other junctions.
  • There is the possibility that an individual backtracked on their route, meaning that a junction could have been visited multiple times.

I am envisioning various constraints that could potentially be used to minimize junction selection error as well as to identify cases of backtracking. Those constraints could involve choosing junctions with the most GPS points, or only pairs of junctions that have a segment connecting them. I could also imagine looking at the timestamps to identify instances of backtracking.

Has anyone done something similar to this who can spare me reinventing the wheel? Or if I'm completely barking up the wrong tree, and there is a Better Way of identifying a network route from GPS traces in a database-driven way, I'd be open to that too!

Your Answer


Browse other questions tagged or ask your own question.