UrbanAnalyst / dodgr

Distances on Directed Graphs in R
https://urbananalyst.github.io/dodgr/
127 stars 16 forks source link

Map matching known paths #210

Closed grobins closed 3 months ago

grobins commented 1 year ago

I have 600,000 trips across a city with known GPS start, end, and waypoints. The waypoints are roughly 100m apart.

I want to get the OSM IDs of all segments visited en-route, so that I can build a volume map of trips per OSM segment.

Is this something I can do with dodgr? So far I've only seen origin/destination examples.

mpadge commented 1 year ago

Thanks for asking @grobins, and the answer is definitely yes. You say you ultimately want a "volume map", which sounds like the flow aggregation functions might be what you want. Those functions generally add an extra column of "flows" to the network, with aggregate flows then directly mapped on to each edge, so you've directly got the OSM ID and corresponding "flow" or "volume".

The trickest bit is likely to be that dodgr does not currently have any way to force routing through specified waypoints, so i guess what you'd need there would be to break each trip into start and end points for each segment. If it's a typical city, 600,000 trips might then translate to 6,000,000 or so individual segements. That kind of job is definitely do-able on a typical laptop. You could use match_pts_to_verts() to initially aggregate the 6 million points to some lesser number of common vertices to improve efficiency.

Let me know if that helps, and feel free to ask any more questions you might have.

grobins commented 1 year ago

Thanks I'll give that a go