[GIS] the best way to extract the geometry of a road from OSM data

geometrygeoprocessingopenstreetmap

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.

Best Answer

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.