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?
There are multiple versions of the Kalman filter.
The idea behind the filter is this:
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.
You have a model of how the states relates to the position.
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.