NREL / mappymatch

Pure-python package for map matching
http://mappymatch.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
65 stars 20 forks source link

Mistakes on Map Matching #157

Closed bernardotepedino closed 1 year ago

bernardotepedino commented 1 year ago

Hi everyone! Could anyone help me with some issues that I am having with the mappymatch algorithm? Attached there is a picture of my mappymatch result, using the same code as shown at the ReadMe. It is possible to see that the algorithm is producing some wrong paths when compared to the real path, that is the blue one. Does anyone know how could I solve this problem? I thought of changing the parameters used to create the object LCSSMatcher, but it didn't work.

The dataset is also attached to this issue!

image

Thank you a lot! Book1.csv

nreinicke commented 1 year ago

Thanks for checking out the package! It looks like this trace might have been the result of a walking or a bike trip. While we've tested our current algorithm extensively for high resolution driving trips we haven't done much work with biking and walk trips (although we hope to improve this in the future).

We have made some recent updates and so you could try installing the latest version pip install mappymatch --upgrade and trying again. I tried on my own machine and was able to get slightly better results:

from mappymatch.constructs.geofence import Geofence
from mappymatch.constructs.trace import Trace
from mappymatch.maps.nx.nx_map import NxMap, NetworkType
from mappymatch.matchers.lcss.lcss import LCSSMatcher

from mappymatch.utils.plot import *

trace = Trace.from_csv("Book1.csv")
geofence = Geofence.from_trace(trace, padding=1e3)
road_map = NxMap.from_geofence(geofence, network_type=NetworkType.WALK)

matcher = LCSSMatcher(road_map)

matches = matcher.match_trace(trace)

plot_matches(matches, road_map)

Results in:

image
bernardotepedino commented 1 year ago

Thank you a lot!

Do you know why there is a noncontinuous point in the middle of the trajectory and how could I solve it? Also, before the noncontinuous point, the street that the algorithm chooses is wrong, which might cause the problem. Do you know why this happened?

Rowlando13 commented 1 year ago

Did updating help? The non contiguous section is weird. Any thoughts at @nreinicke ? Because the data set for walking?

nreinicke commented 1 year ago

Regarding the non-contiguous sections, this behavior is actually expected in some edge cases. The algorithm computes the best fit trajectory for the trace but then it iterates over each point and finds the closest segment within that trajectory which doesn't necessarily include all segments. For example, in the case below:

image

The algorithm would have included the missing segment in the trajectory but when the actual matching is performed, it just so happens that the there are no points in the trace that happen to be closer to the missing segment than than the other two on either side of it.

We could potentially return the full trajectory at the end since it's already been computed.

nreinicke commented 1 year ago

New issue #159 opened to address this.

Rowlando13 commented 1 year ago

Closing this since we opened specific issues for applicable problems this raised.