Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to return the posted speed and number of lanes of a highway segment using Google Maps API, OSM data, or any other stream (paid for or free)?

share|improve this question
Specifically for OSM, are you looking for a way using an OSM API or downloaded OSM data ? – Will. Apr 5 '13 at 18:54
@Will. I'm open to both, preferably be able to use the API; however, I have no issues whatsoever if I can download the data to myserver and use that – dassouki Apr 5 '13 at 21:27
from the OSM website ( you can always export the area of interest in XML and take out the info on the type of road and speed limit. but i am not sure this is how you want to do this. – A.R Apr 6 '13 at 18:35

I will give you a method using downloaded OSM data, as the API is designed for editing and not for read-only. You will find more details on this on the API usage policy page of the OSM wiki. If you really want to use an API, you can look at the read-only APIs like the Overpass API. Several other methods could also work, depending on how you will use this data and which tools you like most.

  • Download OSM data for you area of interest. Use Geofabrik if the area is big, or the OSM website export tab if your area is small (a city or less).
  • Put all this data in PostGIS :
    • Install osm2pgsql and find the file (on Ubuntu : /usr/share/osm2pgsql/
    • Copy this, save it as and edit it to add the following lines so you can retrieve the lanes and maxspeed from OSM:
      way   lanes        text         linear
      way   maxspeed         text         linear
    • Run the following (this is for Ubuntu but should be very similar on Windows):
      sudo su postgres
      createdb gis
      psql -d gis -c "CREATE EXTENSION postgis;"
      psql gis -c "ALTER TABLE geometry_columns OWNER TO postgres"
      psql gis -c "ALTER TABLE spatial_ref_sys OWNER TO postgres"
      osm2pgsql -s --style /path/ -W -U postgres -d gis /file/path/toosm/fileorpbf/name.osm
  • You can now run any query you want on the gis database to get the maxspped and number of lanes of a road segment

Important note: this is a technical method, but there is no guarantee that the speed and number of lanes are present in OSM for the highways you are interested in.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.