Created
June 17, 2023 11:29
-
-
Save joaofig/342f244d554ec60b3a0f304a44d48dfd to your computer and use it in GitHub Desktop.
Map-matches a set of GPS locations to the digital map using Valhalla.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def map_match(actor: Actor, | |
| df: pd.DataFrame) -> str: | |
| param = { | |
| "use_timestamps": True, | |
| "shortest": True, | |
| "shape_match": "walk_or_snap", | |
| "shape": df.to_dict(orient='records'), | |
| "costing": "auto", | |
| "format": "osrm", | |
| "directions_options": { | |
| "directions_type": "none" | |
| }, | |
| "trace_options": { | |
| "search_radius": 50, | |
| "max_search_radius": 200, | |
| "gps_accuracy": 10, | |
| "breakage_distance": 2000, | |
| "turn_penalty_factor": 1 | |
| }, | |
| "costing_options": { | |
| "auto": { | |
| "country_crossing_penalty": 2000.0, | |
| "maneuver_penalty": 30 | |
| } | |
| } | |
| } | |
| route = actor.trace_route(param) | |
| return route["matchings"][0]["geometry"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment