root/branches/workshop/FOSS4G2008/Docs/10_osm2pgrouting.chapter

Revision 236, 3.0 KB (checked in by daniel, 2 years ago)

workshop: osm2pgrouting chapter + fixes

Line 
1= osm2pgrouting data converter =
2
3This tool makes it easy to import OpenStreetMap data and use it with pgRouting.
4It creates topology automatically and creates tables for feature types and road
5classes.
6osm2pgrouting was primarily written by Daniel Wendt and is now hosted on the
7pgRouting project site:
8http://pgrouting.postlbs.org/wiki/tools/osm2pgrouting
9
10== How to install (Ubuntu 8.04) ==
11
12Check out the latest version from SVN repository:
13{{{
14svn checkout http://pgrouting.postlbs.org/svn/pgrouting/tools/osm2pgrouting/trunk osm2pgrouting
15}}}
16
17Required packages/libraries:
18
191. PostgreSQL
202. PostGIS
213. pgRouting
224. Boost library
235. Expat library
246. libpq library
25
26Note: if you already compiled pgRouting point 1. to 4. should already be
27installed.
28
29Then compile
30{{{
31cd osm2pgrouting
32make
33}}}
34
35== How to use ==
36
371. First you need to create a database and add PostGIS and pgRouting functions:
38{{{
39createdb -U postgres osm
40createlang -U postgres plpgsql osm
41
42psql -U postgres -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql osm
43psql -U postgres -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql osm
44
45psql -U postgres -f /usr/share/postlbs/routing_core.sql osm
46psql -U postgres -f /usr/share/postlbs/routing_core_wrappers.sql osm
47psql -U postgres -f /usr/share/postlbs/routing_topology.sql osm
48}}}
49
502. You can define the features and attributes to be imported from the
51OpenStreetMap XML file in the configuration file (default: mapconfig.xml)
52
533. Open a terminal window and run osm2pgrouting with the following paramters
54{{{
55./osm2pgrouting -file /home/foss4g/capetown_20080829.osm \
56                                -conf mapconfig.xml \
57                                -dbname osm \
58                                -user postgres \
59                                -clean
60}}}
61
62Other available parameters are:
63{{{
64 * required:
65        -file   <file>          -- name of your osm xml file
66        -dbname <dbname>        -- name of your database
67        -user   <user>          -- name of the user, which have write access to the database
68        -conf   <file>          -- name of your configuration xml file
69 * optional:
70        -host   <host>          -- host of your postgresql database (default: 127.0.0.1)
71        -port   <port>          -- port of your database (default: 5432)
72        -passwd <passwd>        --  password for database access
73        -clean                          -- drop peviously created tables
74}}}
75
764. Connect to your database and see the tables that have been created
77{{{
78psql -U postgres osm
79\d
80                 List of relations
81 Schema |        Name         |   Type   |  Owner   
82--------+---------------------+----------+----------
83 public | classes             | table    | postgres
84 public | geometry_columns    | table    | postgres
85 public | nodes               | table    | postgres
86 public | spatial_ref_sys     | table    | postgres
87 public | types               | table    | postgres
88 public | vertices_tmp        | table    | postgres
89 public | vertices_tmp_id_seq | sequence | postgres
90 public | ways                | table    | postgres
91(8 rows)
92}}}
93
94Note: If tables are missing you might have forgotten to add PostGIS or pgRouting
95functions to your database.
96
97Let's do some more advanced routing with those extra information about road
98types and road classes.
Note: See TracBrowser for help on using the browser.