I have a problem like this: I have a list of latitude, longitude pairs and for each one of those, I would like to know which type of road was it generated on. All the points are from GPS units of cars driving on public roads.
I have downloaded OpenStreetMap .osm export, where the roads are stored in a format as follows:
Now my question is, is there any tool to find a match between GPS coordinates and this way ids? How is this done using OpenStreetMaps?
Map Matching: the process of taking your GPS trace and snapping it to road features. Graphhopper provide tools for doing this as part of their routing engine.
In both of the latter cases if your point is near 2 or more roads you need some way to select the road you want, but both are rather simpler than the former.
This returned an XML string where I could parse for a way id.
The major issue with this approach is that when your GPS point is close to multiple roads, you get an XML response with multiple way ids. In my solution I have totally neglected this and I am fine with any error this might give. Since my dataset is very large and dense I assume the error made would not be significant and early experiments proved me right.
How would you find out the type of road by looking at the way id?
BTW: I would use larger batches instead of calling osm3s_query for each single lat/lon. “Zero” values separate way ids for each lat/lon pair. Also by using CSV there’s no need to parse any XML.
[out:csv(::id;false;"")];
way(around:50,51.946,-1.185)["highway"]; out; make sep ::id = 0; out;
way(around:50,51.946,-1.285)["highway"]; out; make sep ::id = 0; out;
way(around:50,51.946,-1.385)["highway"]; out; make sep ::id = 0; out;
way(around:50,51.946,-1.485)["highway"]; out; make sep ::id = 0; out;
If one is doing large batches, one should probably be considering the high level objective that you are trying to achieve, as it is possible there may be features about it that mean that the process can be done more efficiently, and, in extreme cases, it may be that it is inappropriate to use the public servers and you should be working with a local copy of the part of the world that you are interested in.
In particular, if you your set of points is very dense, the correct approach may be to look up the ways in the points, rather than the points in the ways. That would need to be done with a local copy.
Oh. I might have not expressed myself very well. I am interested in the way id as a number + all the parameters the way id has such as “highway” (AKA the type of the rode), “surface”, “maxspeed”, etc.