By David Crowther
Question:
Can you undertake point to point routing in QGIS?
Answer:
Yes, in this previous FAQ we started to explore the QGIS plugin – Valhalla – to undertake drivetime isochrone analysis.
https://www.cadlinecommunity.co.uk/hc/en-us/articles/4410465055377-QGIS-Valhalla-Isochrones
We will use the same Valhalla plugin to now run Point to Point routing.
Open the QGIS Plugins tool and search for Valhalla.
Once you have found the plugin, choose Install Plugin.
It will be installed and accessible under the Web menu.
To use the Valhalla tool, you will need to setup the Provider Settings. Before we do that, we will need to get our API key from the provider of the online routing service, which is MapBox.
If you haven’t already created a MapBox account, then follow this blog to get started –
Within MapBox you can choose the Navigation > Directions API page.
On the Directions API page, copy the public access token shown in the window to the left of the map.
Back in QGIS, choose Web > Valhalla > Provider Settings and choose the MapBox option.
Paste in the public access token into the API Key window and press OK.
To now run the tool, choose Web > Valhalla > Valhalla.
Choose the Provider to be MapBox, and then in the Valhalla window choose the task you wish to perform, which include:
- Point to Point Routing
- Isochrones
- Source to Target
- Locate
- Centroid
- Extract
In this example, we will choose the route option (which gives us Point to Point routing), and from the Go With option we can choose automatic, truck, bicycle or pedestrian.
We will choose auto.
Then from the Mode we can either choose fastest or shortest – dependent on the task you have.
To now generate the point-to-point route , you need to add a starting and ending point into the map.
- To add one starting point, choose the green plus button and left click in the map at your chosen start location.
- To add stop off locations, choose the green button and left click in the map to add multiple stop locations.
- Finally,… to add an end location, choose the green button and left click in the map to the ending point.
The starting, stop off and end points are then added into the Valhalla tool window.
If you need to remove a starting point, select the point in the list and choose the Red X button.
There are then a number of settings and parameters that you can choose, including:
- Costing Options
- Avoid Locations
Choose Costing Options. These allow you to set the routing options e.g. if Tolls should be avoided etc…
Choose Avoid Locations. These are locations that the route must avoid, and they can be loaded from a layer.
Having changed the configuration as desired….choose Apply, and the point-to-point routing will be calculated.
The output is a scratch layer, which has is a line object representing the optimum route from the start to the end point, including any stop offs.
Why not download the Valhalla plugin yourself and see how you can create point to point routes using your data? It’s a great way to undertake spatial analysis such as:
- quickest route to a School
- best route to take to make drop offs/stop offs e.g. for a Maternity Nurse doing home visits.
Comments (0 comments)