[OSM-talk] Version 0.5 osm to shapefile ?

Frederik Ramm frederik at remote.org
Fri Dec 14 16:24:30 GMT 2007


Hi,

> In the 0.4 days, there were a number of tools to convert osm files to
> a GIS/ogr compatible format
> (http://wiki.openstreetmap.org/index.php/Converting_OSM_to_GML,
> osm2shp, etc). None of these seem to work "out of the box" with
> version 0.5 osm files.

Check out Jochen's brand new ruby toolbox:

http://osmlib.rubyforge.org/

You can define what parts of the OSM data get exported and how, and  
you have all the flexibility of a scripting language to do it. For  
example, to export all railway lines to a shape file, you need a  
configuration like this:

setup :Shp do
     polyline :rail_lines do
         string :ID, 20
     end

     point :rail_stations do
         string :ID, 20
         string :Name, 100
         string :UIC, 20
     end
end

nodes do
     if railway=='station'
         :rail_stations << {:ID => id, :Name => name, :UIC => uic_ref}
     end
end

ways do
     if railway=='rail'
         :rail_lines << {:ID => id}
     end
end

(this creates two shapefiles, one for lines and one for points).

Or make a shapefile with all roads and their types:

setup :Shp do
     polyline :road do
         name 'Road'
         string :Name, 100
         string :Type, 20
         string :Oneway, 8
         number :Maxspeed, 4
     end
end

ways do
     if highway
         :road << {:Name => name, :Type => highway, :Oneway =>  
oneway, :Maxspeed => maxspeed}
     end
end

... you get the point. The tool can also generate CSV and KML files.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'






More information about the talk mailing list