transbigdata.traj_mapmatch

transbigdata.traj_mapmatch(traj, G, col=['lon', 'lat'])

Nearest map matching: Find the nearest point on the road network for each trajectory point. When conducting nearest neighbor matching, we need to find the closest road segment on the road network for each trajectory point, and match the trajectory point to that segment. In practice, we can first extract the nodes of the road segments to form a set of points (i.e., extracting each coordinate point from each LineString in the geometry column), then calculate the nearest distance between the trajectory point and this set of points, and finally match the trajectory point to the road segment where the nearest distance’s node is located. This process effectively transforms the problem of matching points to lines into a problem of matching points to points.

Parameters:
  • traj (DataFrame) – The trajectory point data set to be matched.

  • G (networkx multidigraph) – The road network used for matching, created by osmnx.

  • col (list) – The name of the longitude and latitude columns in the trajectory point data set.

Returns:

traj_matched – The trajectory point data set after matching.

Return type:

DataFrame