Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

2 Answers

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():

http://postgis.net/docs/reference.html#Linear_Referencing

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
add comment

The easiest way is to download SHAPE files from http://download.geofabrik.de/osm/ . 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
1  
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: download.cloudmade.com (currently two months old) –  Michal Migurski Feb 13 '12 at 20:15
2  
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 download.geofabrik.de/osm/south-america –  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
add comment

Your Answer

 
discard

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.