I am looking for (the name of) a geometric algorithm for cartographic generalization of a street map.
In my map data, I have many paths (ordered list of points, connected by line segments) that lay close and almost parallel to one another. How do I (1) identify these “adjacent pathsˮ (i.e. how to find paths that are closer than a certain threshold) and (2) merge them into one path (i.e. how to compute the centerline between close paths)?
As an example, consider the following graph of roads / lanes of roads created with data from OpenStreetMaps:
As you can see, the two lanes of the road running horizontally are modeled as two separate paths. For detail views this is useful, but for a more zoomed out view I need to merge the two paths (lanes) to display only one line for the road.
What are the established algorithms used in map renderers to achieve this? Obviously, Google Maps, OSM, etc. do this -- how?
I had studied a problem similar to this as a researcher. my paper on frequent route This is about given a bunch of trajectories (at different time/speed), how to reverse-engineer the road segments.
You can use Frechet distance to measure the distance between segments and cluster the line segments using the distance. For each cluster, you can assign a representative line-segment. That's the gist of the solution.
A simplier way to achieve is using the following algorithm:
def reduce_segments (G : graph):
for e in G.edges:
if not e.mark:
continue
similar_edges = get_all_edge_with_frechet_distance_less_than_thr(G.edges, thr)
for se in similar_edges:
se.mark = True
return {ee : ee in G.edges and ee.mark == False}
This is not what it's for, but how about doing something like a Hough transform?
To find close-enough paths:
To merge the two paths:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With