pgRouting is an extension of PostGIS (geospatial database), which in turn, is an extension of PostgreSQL database system. It adds routing capabilities and network analysis functionalities to the PostGIS geospatial database. You can perform different network analysis, shortest paths, driving distances, service areas on a topological corrected network.
To be able to perform route analysis in QGIS using pgRouting you have to follow some specific steps as follow:
- Install PostgreSQL
- Install PostGIS and pgRouting
- With pgAdmin (that comes installed along with PostgreSQL) connect to the database and create a new one, enable its spatial and routing capabilities.
- Import the network layer into the database.
- Use QGIS and connect to the newly created database. Use Browser Panel > PostGIS > New connection.
- Create all the necessary attributes needed for route computation – length, speed, time to cross all the sections of the network. They can be called also, cost of crossing (for a section of the road).
- Check the network topology with Topology Checker. Also create the PostGIS topology using pgAdmin.
- Install the pgRouting Layer plugin.
After all these steps you should be able to load the layer into QGIS map canvas from your PostGIS database just created.
Now we are ready to perform route analysis using pgRouting. Go to View > Panels > pgRouting Layer.
Clicking Preview, the algorithm will compute the shortest route between the selected points (start and end).
For more details please consult our QGIS Advanced level course.
Thank you very much for the information, I think the extension is very useful.
Do you have more information of step 4 “Import the network layer into the database”, I am curious about how the network layer is populated.
Thanks and Best Regards,
I have not had problems until point 5. It has been impossible to load the database. The database field of pgrouting layer in qgis is disabled. What is the cause of that?