get speed limits from OpenStreetMap

user2233166 picture user2233166 · Apr 1, 2013 · Viewed 15.3k times · Source

I'm creating a mobile app that determines if someone if a good driver. The phone sits on the dashboard and collects GPS information while the user is driving. I need to determine a way if the driver is following the speed limit, and I would like to do this via OpenStreetMap. What is the best way to get speed limits from OpenStreetMap?

Answer

Papou picture Papou · Sep 11, 2013

You can make a Web request to get your answer.
Here is one (try it as a browser URL) of a small box where you're supposed to be:

www.overpass-api.de/api/xapi?*[maxspeed=*][bbox=5.6283473,50.5348043,5.6285261,50.534884]

and the answer showing the street passing through it, in front of a school:

<node id="1312239864" lat="50.5348877" lon="5.6286790">
  <tag k="highway" v="crossing"/>
  <tag k="traffic_calming" v="bump"/>
</node>
<node id="2025084665" lat="50.5345623" lon="5.6274183">
  <tag k="traffic_calming" v="choker"/>
</node>
...
<way id="191950462">
  <nd ref="2025084669"/>
...
  <tag k="bicycle" v="yes"/>
  <tag k="highway" v="secondary"/>
  <tag k="maxspeed" v="30"/>
  <tag k="name" v="Rue d'Esneux"/>
  <tag k="source:maxspeed" v="school zone"/>
</way>

I only left the interesting stuff in, most self explanatory. For example, traffic calming features on their own node.
The street is the way made of the nodes and of its own tags.
maxspeed=30 is your answer. Should there be no maxspeed, the default applies for highway=secondary (or =motorway ...)
All the tags are described at wiki.openstreetmap.org
That's using xapi. You may also use the overpass api.
Speed limit coverage is partial but you may improve it. Leave Notes on the main map to provide the data.