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

What is the best way to extract the geometry of a road from OSM data? The goal is to display segments of highway that are closed due to weather. The weather data consists of positions (in KM measured along the road) from major cities, and length of the affected stretch of road. The main problem is clipping the road based on these distances; afterwards rendering seems straightforward.

share|improve this question
up vote 4 down vote accepted

You definitely want to get that data into Postgis using something like osm2pgsql or imposm (if all you have is an .osm extract) or shp2pgsql (if you have a shapefile). Once your data is in Postgis, you can use some of the linear referencing functions explained here, esp. ST_Line_Interpolate_Point() and ST_Line_Locate_Point():

I imagine that the error in the linear referencing is going to be a major problem. If you have long distances in km and the OSM road is a different geometry to what the weather service uses, then you you'll see errors magnified the further you go.

share|improve this answer

The easiest way is to download SHAPE files from . They contain a "roads" layer (these files are updated overnight).

The connected attribute table allows you to quickly categorize the streets in a hierarchical way.

Another layer in the package is (for some cities) the extent.

Hence, subsequent clipping can be done e.g. with QGIS or GRASS GIS.

share|improve this answer
Markus, there are no shapefiles available at the Geofabrik extracts page. – Michal Migurski Feb 13 '12 at 20:10
Cloudmade does make them, though they are often out of date: (currently two months old) – Michal Migurski Feb 13 '12 at 20:15
Actually, there are shape files. You just have to drill down to the specific region folders. You have the option of getting the bz2, pbf or shape files. For example, here's the South America files – R.K. Feb 14 '12 at 14:17
@Michal: as mentioned by R.K. just change into the subdirectory of interest. And they are regularly updated! – markusN Feb 15 '12 at 0:20

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.