Closed creatorLEI closed 2 years ago
I assume it didn't match any states, the lastidx is also 0 (which is the last location that is matched). This is probably because you are using BaseMatcher
which is an empty matcher. You can try SimpleMatcher
or DistanceMatcher
.
What is the difference between these three "matchers"?
BaseMatcher
is a skeleton class to provide generic auxiliary methods. We could make it an abstract class.SimpleMatcher
is a simple probabilistic approach where if observation and matched location are far apart, the probability is low.DistanceMatcher
is a variation on the matcher proposed by Newson and Krum (GIS 2009) where the probability of is also reduced if the distance between two observations is different from the distance between two matched locations.Thank you very much! And I find that the value of "max_dist" in "BaseMatcher" is larger, runing time is longer. But with the larger value, it can match more observation. However, when the value is up to 1000, it will cost so much time that not once in the many times I have run I could wait it finish. So can you recommend me a proper value?
In version 1.0, the max_lattice_width
option was added for this reason. See also the docs on https://leuvenmapmatching.readthedocs.io/en/latest/usage/introduction.html . This allows you to have larger values for max_dist
etc, thus allow more deviation, while keeping the runtime limited. In our applications, we run the matcher with a value of 10 or smaller.
Thanks a lot! And I have another question. Now I matched GPS observation on my map, but I don't know which state segment the GPS point exactly in and how long is a state segment(along the road, not the straight-line distance) . Help me please, thanks!
I'm not sure what you are asking for exactly, but all information about the matching can be found in matcher.lattice_best
. Each entry in that list is a Matching
object which in turn has all information about each match. Concretely, a edge_o.pi
and edge_m.pi
attribute that tells you which observation location links to which map location.
Thank you very much! Concretely, how can I write the code which can call "edge_o.pi" and "edge_m.pi"? And how can I obtain the distance of each road segment in each entry of "matcher.lattice_best" list? such as the distance between "5018470949" and "5018470948" in row[0] as shown in picture.
These are entries of type BaseMatching. So getting the interpolated position of, for example the first entry, is matcher.lattice_best[0].edge_m.pi
.
The distance between two nodes such as 5018470949 and 5018470948 is not included in the matching. This can be directly computed from your map/database using any library that supports coordinates / haversine (or the relevant functions in util.dist_latlon
).
Thanks! You help me a lot!
And if I want to obtain the distance along the road, not the straight line distance, between two nodes, is there any function in matching to realize it?
There wasn't but it's quite easy so I added one in commit dfdaf6a. You can call matcher.path_pred_distance()
. It will only be part of the next release, so if you want to use it immediately you'll have to install from the github master branch (see https://leuvenmapmatching.readthedocs.io/en/latest/usage/installation.html).
OK,thanks! And what is ".edge_m.pi"? I compared it with matching points and observation points, but they are all different. And another question is that if "m_prev.edge_m.label == m.edge_m.label", in other words, if I have more than one observation points in the same matching segment, what are "m_prev.edge_m.pi" and "m.edge_m.pi"?
I want to find the corresponding way id of my GPS points, by the way, my GPS data has non-zero speed. But when I debug the "BaseMatcher", as shown in the first picture, I find "states" is an empty list. However, the matching picture is fine as shown in the second picture. I don't know why the list is empty. Is there anyone kindful to help me?