In this recipe, we will create a routing network from scratch using the QGIS editing tools. Even though more and more open network data is available, there will still be numerous use cases where necessary network data does not exist or is not available for use. Therefore, it is good to know how to create a network and what to pay attention to in order to avoid common pitfalls.
For the task of network creation, the main difference between the Road graph plugin and pgRouting is that pgRouting needs a network node (that is, link start or end node) at each intersection while the Road graph plugin will also use intermediate link geometry nodes to infer intersections if two links share a node. In this recipe, we will create a network, which can be used in both tools.
To follow this recipe, you only need a new empty QGIS project. Additionally, make sure you have the Digitizing toolbar enabled (as shown in the following screenshot). We will create an imaginary network, but if you want you can load a background map and digitize this:

Before we can start to create the network, there are a few things that need to be set up first:
You can read more about creating new shapefiles in the Learning QGIS book by Packt Publishing and the QGIS user guide at http://docs.qgis.org/2.2/en/docs/user_manual/working_with_vector/editing_geometry_attributes.html#creating-a-new-shapefile-layer.


The line in the preceding screenshot is drawn with a style that has circles on the starting and ending points. You can reproduce this style by adding the Marker line symbol levels to the line style or load network_links.qml from our sample data. For more details about styling features, please refer to Chapter 10, Cartography Tips.

We will use this basic network as a starting point for the remaining recipes in this chapter.
By setting the snapping mode to to vertex, we made it possible to digitize the line network in a way that ensures that lines, which should be connected, really contain a node at the exact same position.
You can validate the network topology by running the Topology Checker plugin, which is installed with QGIS by default (you can read more about Topology Checker in Chapter 12, Up and Coming):

