[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

------------------------------
#!/bin/bash
awk -F\" 'BEGIN{
 i=-1;j=-1; 
 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;
          nodelon[$2]=$6;
         } 
        if ($1 == "  <segment id=") 
         {
          seg[j++]=$2; seg_start[j]=$4;
          seg_end[j]=$6;
         } 
}
END{
for(k=0;k<i;k++)
{
 print "point",nodelat[nodes[k]],nodelon[nodes[k]] >>
"planet.mif"
 print nodes[k] >> "planet.mid"
}
for(k=0;k<j;k++)
{
 print
"line",nodelon[seg_start[k]],nodelat[seg_start[k]],nodelon[seg_end[k]],nodelat[seg_end[k]]
>>"planet.mif"
 print seg[k] >> "planet.mid"
}
}' planet.osm


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the talk mailing list