9. Using Qgis


Other kind of functions are pl/pgsql. As applications requirements become more complex, using previously defined functions becomes necessary.

9.1. Set Up QGIS

Graphs have a set of edges and set of vertices associated to it. osm2pgrouting provides the ways_vertices_pgr table which is associated with the ways table. When a subset of edges is used like in vehicle_net or in small_net, the set of vertices associated to each one must be used in order to, for example, locate the nearest vertex to a lat/lon location.

  1. Launch QGIS from Geospatial ‣ Desktop GIS ‣ QGIS and select Project ‣ Open from the menu bar.



    The location of QGIS may vary.

    The workshop instructions are based on QGIS 2.14 Essen

  2. Close the broswer pannel

  3. Connect to a posgGIS enabeled potsgreSQL database clicking on Add postGIS layer

  4. Create a new connection clicking on New

  5. Fill the information and test the connection


    Name city_routing

    Host localhost

    Port 5432

    Database city_routing

    User name user

    Password user

  6. Allow qgis to remember login and password


9.2. Add a postGIS Layer

Click Connect and a list of tables and views from the database will show.

It is necessaary to select the column that has a distinct unique value:

  • seq on the routing views
  • gid on the data views

9.3. Format a Routing Layer

  1. Choose a routing view, Right click ‣ Zoom to Layer

  2. Right click ‣ Properties

  3. Style ‣ Color

  4. Style ‣ + ‣ Symbol Layer Type ‣ Marker line

  5. Apply ‣ Close

9.4. Copy/Paste Format

  1. Choose a formmated layer and Right click ‣ Styles ‣ Copy Styles

  2. Choose another layer and Right click ‣ Styles ‣ Paste Styles


9.5. Save the project

  1. Project ‣ Save As ...

  2. Navigate to: User ‣ Desktop ‣ workshop and save pgrouting-Boston-Example