wannesm / LeuvenMapMatching

Leuven.MapMatching toolbox for aligning GPS measurements to locations on a map.
Other
222 stars 43 forks source link

How to deal with links whose geometry is composed of multi-line strings instead of line segments? #53

Closed JunzeYang closed 4 months ago

JunzeYang commented 5 months ago

Hello,

I am currently working on a city-level map matching project using GPS trajectories, where the road network is simplified by removing pseudo nodes between adjacent links. Therefore, the geometry field in the GeoDataFrame links is multi-line strings in LineString format representing actual road geometry, rather than line segments connecting the head and tail nodes of links. However, when creating the InMemMap object map_con, it seems that I can only add node coordinates using add_node(node, loc) and add links using add_edge(node_a, node_b). The resulting links are line segments connecting head and tail nodes (left figure), rather than multi-line strings aligned with the actual map (right figure), which could lead to inaccurate map matching. Since the network is large, is it possible to achieve this requirement without adding new nodes?

Thanks a lot!

framework

wannesm commented 5 months ago

You need to translate the multi line strings to individual lines and add the nodes in between. The toolbox assumes straight lines.

If you are using the osmnx toolbox to read OpenStreetMap, this is also achieved by setting the simplify attribute to false and not applying the simplify_graph function. OSM only has straight edges by default and multiline segments are a simplification of the OSM map.

JunzeYang commented 5 months ago

OK, I will try out your suggestions. Many thanks!