[OSM-talk] Using OSM with PostGIS

Johnny Doe uucp1 at yahoo.com
Sat Apr 15 15:38:02 BST 2006

--- Alex Willmer <alex at moreati.org.uk>

> If you manage
> to connect please take a screenshot and post it to
> the wiki. I'll do the
> same once I get QGIS working again.

The easiest way to import the planet.osm into Qgis is
to convert it into mapinfo format. It is very simple
and does not require any bizarre tools. 
Parsing the tags and splitting into the layers is
left as an exersise to the reader.
If the layers are split, then you can produce the
"point" and "linestring" shapefiles with ogr2ogr:
ogr2ogr -f "esri shapefile" nodes.shp nodes.mif
ogr2ogr -f "esri shapefile" segments.shp segments.mif

awk -F\" 'BEGIN{
 system("rm -f planet.mi?");
printf("version 300\ncharset \"utf-8\"\n\
coordsys earth projection 1, 104\n\
delimiter \",\"\n\
columns 1\n\
cat integer\n\
data\n") >"planet.mif";
        if ($1 == "  <node id=") 
          nodes[i++]=$2; nodelat[$2]=$4;
        if ($1 == "  <segment id=") 
          seg[j++]=$2; seg_start[j]=$4;
 print "point",nodelat[nodes[k]],nodelon[nodes[k]] >>
 print nodes[k] >> "planet.mid"
 print seg[k] >> "planet.mid"
}' planet.osm

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the talk mailing list