GPS to way id matching in OpenStreetMaps

712 views Asked by At

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:

<way id="88596345" visible="true" version="9" changeset="453983438" timestamp="2017-05-04T15:47:48Z" user="wegavision" uid="453845">
  <nd ref="456877786"/>
  <nd ref="3335483999"/>
  <nd ref="248335839"/>
  <nd ref="406453920"/>
  <nd ref="25808860"/>
  <tag k="destination" v="abcd"/>
  <tag k="highway" v="secondary"/>
  <tag k="lanes" v="1"/>
  <tag k="lit" v="yes"/>
  <tag k="maxspeed" v="30"/>
  <tag k="oneway" v="yes"/>
  <tag k="ref" v="M54"/>
  <tag k="sidewalk" v="left"/>
  <tag k="smoothness" v="good"/>
  <tag k="surface" v="asphalt"/>
 </way>

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?

1

There are 1 answers

0
Erhan On BEST ANSWER

Okay, so in the end I figured it out as follows:

First, I have installed an Overpass API on my Ubuntu machine and loaded the downloaded .osm there. Then I could query the loaded .osm file like this:

/some_path/osm-3s_v0.7.54/bin/osm3s_query --db-dir=/some_path/osm-3s_v0.7.54/mydb <<< "way['highway'](around:10,'_GPSLAT_,_GPSLON_');out;"

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.