Reputation: 11383
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?
Upvotes: 13
Views: 3423
Reputation: 3512
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}
Upvotes: 3
Reputation: 496
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:
Upvotes: 3
Reputation: 1769
To find the distance between path A
and path B
:
X
on path A
Y
at 90 degrees to the line between point X
and the next point.Y
with one of the lines in the
path B
X
and intersection point and you get the
space between the paths at point X
.To create a path between two paths:
Upvotes: 0