Analyzing Geographic Data with Python — Map Matching with LeuvenMapMatching Package

Renee LIN
7 min readOct 1, 2023

In the last post, I obtained the street network I wanted to use. Subsequently, the trajectory/GPS data had to be matched to the streets. This is necessary because GPS readings provide pure latitude and longitude coordinates, but we want to know the specific roads on which the vehicle is travelling.

I first tried a naive way to match the points, matching each point independently to the nearest road segment. If there is no road, just enlarge the buffer distance range. It won’t be accurate because the GPS data itself is noisy, and the roads might be complex. If you googled, you could find this StackOverflow post in no time, directing to a Python package called LeuvenMapMatching. I’d like to share:

  1. How to use the library
  2. Visually validate the matched result
  3. The process and key parameters explained

1. How to use the library

(1) The trajectory data

I am currently working with Pneuma, from which numerous trajectories can be extracted. The data should consist of a list of tuples representing the locations. Here, I am using the data from Zone 1 on October 30, 2018, as an example.

--

--

Renee LIN
Renee LIN

Written by Renee LIN

Passionate about web dev and data analysis. Huge FFXIV fan. Interested in health data now.

Responses (1)