The previous recipe, Visualizing pgRouting results in QGIS, showed you how to manually add pgRouting results to the map. In this chapter, we will use the pgRoutingLayer plugin to get more convenient access to the functions that pgRouting offers, including the most basic algorithms, such as Dijkstra's algorithm, which we have used so far, to more complex algorithms, such as drivingDistance and alphashape, which can be used to visualize catchment zones, also known as service areas.
You should first go through the previous recipe, Creating a routing network for pgRouting, to set up the necessary PostGIS tables. Alternatively, you can use your own network tables, but be aware that you may have to alter some of the SQL statements if your table uses different column names.
Additionally, install the pgRoutingLayer plugin from Plugin Installer. You will need to enable experimental plugins in Settings to view this.
The pgRoutingLayer plugin adds a new panel to the QGIS GUI, which allows convenient access to the available routing functions. The following steps show you how to use this plugin:
dijkstra function. You will recognize the parameters from the previous recipes where we wrote the pgRouting SQL query manually.edge_table) and the geometry, id, source, target, and cost columns, as shown in the following screenshot:
alphashape function. The rest of the input fields adapt automatically to the selected function.
When we click on the Run button, the query results are visualized as a temporary overlay on the map. If you want to save the output permanently, you can click on the Export button. Currently, the Export button is only available for the routing functions but not for the service area functions.
For a detailed documentation on the pgRouting algorithms, refer to the project documentation website at http://docs.pgrouting.org/2.0/en/doc/index.html.