I have a number of vehicle trajectories(telematic data) stored in a relational database, (Long, Lat, speed) in each second, the points are already map-matched as I have also the road ID from OSM. I want to clean them from any outliers, what I've seen is that the most error in my data is when a vehicle have a speed of 0 (car is stopped), the Long and Lat have different values (GPS error). What I understood is that Kalman filter is used for real time tracking, I don't know if I can use it here? Knowing that I have a big database of trajectories, what are the best options out there?

  • 1
    Hi roger, based on my experience, Kalman filter is a kind of estimation technique that uses observations available to a given system to estimate some of its states (e.g., position and velocity). In your case, it might be better to apply techniques of outlier detection and removal (e.g., median absolute deviation) and/or of data smoothing (e.g., moving average). Hope this helps. – fastest Jun 17 '20 at 15:50
  • @fastest thanks, does this also applicable to speed? – roger Jun 18 '20 at 1:30

There are multiple versions of the Kalman filter.

The idea behind the filter is this:

  1. You keep track of a vector of states of the system (i.e. position, speed, acceleration and noise) and update it for each new data. When post-processing data you can initialize de filter on a forward pass and then use the backwards for estimation.

  2. You have a model of how the states relates to the position.

  3. The update is computed in such a way that, if the underlaying model is accurate, the filter states converges to the optimal linear estimator of the position whith respect to the states.

In your case, maybe you can save the filter speed states and later filter the points on low speed sections (by averaging n samples, increasing n when speed decreases). May be your speed data is reliable enough and you can use that information and forget Kalman.

Here is a good resource on Kalman and other adaptive filters: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python

As others suggested, maybe Kalman filter is not the best choice on your case, and you should search simpler filters like Moving Average.

  • Thanks @Javier, In fact, my data is not being updated, as I have it on a relational database in this format: (trajectory_id,lat, lon, speed, timestamp, road_osm_id) knowing that the points were taken each second. Is this applicable in my case? – roger Jun 18 '20 at 20:10
  • @roger You can apply the filter as if the data were updated. Think of a simulation, the filter won't know the end of the story. You feed the data to the filter one line at a time. I insist you check if moving average filter with a window width defined by your speed serves your purpose. It can be implemented with window functions inside the DB. I would start testing the idea on a single trayectory using python/pandas or just a spreadsheet. – Javier JC Jun 18 '20 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.