Difference between revisions of "Network Analysis: Finding shortest path in QGIS"
Line 14: | Line 14: | ||
== Road Graph Plugin== |
== Road Graph Plugin== |
||
− | * Activate the Tool |
+ | * '''Activate the Tool''' |
[[File:plugin.PNG|400px|thumb|left]] |
[[File:plugin.PNG|400px|thumb|left]] |
||
Line 74: | Line 74: | ||
− | * Configure the Tool |
+ | * '''Configure the Tool''' |
[[File:Config.PNG|200px|thumb|left]] |
[[File:Config.PNG|200px|thumb|left]] |
||
Line 130: | Line 130: | ||
− | * Use the Tool |
+ | * '''Use the Tool''' |
Suppose we want to calculate the distance in length from Canadian Museum of Nature to Canadian War Museum. |
Suppose we want to calculate the distance in length from Canadian Museum of Nature to Canadian War Museum. |
||
In the plugin panel, click on the Capture Point button next to the Start field: |
In the plugin panel, click on the Capture Point button next to the Start field: |
||
Line 224: | Line 224: | ||
+ | |||
⚫ | |||
+ | |||
+ | |||
+ | |||
⚫ | |||
What happens when different street in the network road have different speed limits? |
What happens when different street in the network road have different speed limits? |
||
Line 249: | Line 253: | ||
Call this new column '''SPEED''', and give it the type '''Whole number (integer)''' with a width of '''3'''. |
Call this new column '''SPEED''', and give it the type '''Whole number (integer)''' with a width of '''3'''. |
||
+ | |||
+ | Now we had to run some selection attribute query over the road layer, in order to specify the speed limit 50 km/h for the private roads,60 for public roads with the name BRONSON, 45 km/h for the public roads with name GLOUCSTER and 30 km/h for the rest of the roads. |
||
+ | On the bottom left corner of the Attribute Table, there is a ''Show All Features'' button. Click on the arrow and select ''Column Filter'': Then choose for example '''TYPE''', because we want to select the private roads. As you write rt_private automatically will appear the ''Advanced Filter expression''. |
||
+ | * Select private roads and assign the speed limit by using Advanced Filter expression |
||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Revision as of 23:36, 16 December 2014
Contents
Introduction
Calculating the shortest distance between two points is a commonly cited use for GIS. QGIS ships with this tool, but it’s not visible by default. In this tutorial we will show you what you need to get started.
Data
Acquired QGIS (version 2.6)
You need to install Quantum GIS version 2.6 in order to get activate the road graph plugin.
Road Graph Plugin
- Activate the Tool
To activate the Road Graph plugin: Start the Plugin Manager by clicking on the QGIS main window’s menu item Plugins ‣ Manage Plugins. A dialog appears. Click OK on the Plugin Manager dialog.
This panel will appear in your interface
If the plugin doesn't show automatically in your interface, go to View ‣ Panels and ensure that Shortest path has a check mark next to it.
- Configure the Tool
Time Unit and Distance Unit we leave as default in hour and kilometer. Topology tolerance: In case if there is a gap between two lines to treat them as continuous, the topology tolerance may be applied, for example 10m. In our case we left as default 0. On the Transportation Layer, we choose the layer of the roads. In this case the clipped roads. For the direction field we leave as default. In other cases, while in the attribute table we might have a direction field, we might use the value of this field for direction. For this project we don't have any data for the direction. We keep the speed limit as default. And we choose the speed limit value under the Default Settings tab. For this example the speed was chosen 60 km/h as shown in Figure below.
- Use the Tool
Suppose we want to calculate the distance in length from Canadian Museum of Nature to Canadian War Museum. In the plugin panel, click on the Capture Point button next to the Start field:
Click point that represent Canadian Museum of Nature as start point. Use the Capture Point button next to the Stop field and capture the point of Canadian War Museum.
Click on the Calculate button to see the solution:
The result for the shortest path is shown below. This is a simple case, where the speed mode is the same for all the streets, 60 km/h.
- Using Criteria
What happens when different street in the network road have different speed limits?
The idea is to set different speed limit for some of the selected streets by us. In this case we had to add a new field in the roads layer and call it Speed. Right click on the roads layer.
Open attribute table and select the Toggler button to set on the edit mode .
After that click the New Column icon.
Call this new column SPEED, and give it the type Whole number (integer) with a width of 3.
Now we had to run some selection attribute query over the road layer, in order to specify the speed limit 50 km/h for the private roads,60 for public roads with the name BRONSON, 45 km/h for the public roads with name GLOUCSTER and 30 km/h for the rest of the roads.
On the bottom left corner of the Attribute Table, there is a Show All Features button. Click on the arrow and select Column Filter: Then choose for example TYPE, because we want to select the private roads. As you write rt_private automatically will appear the Advanced Filter expression.
- Select private roads and assign the speed limit by using Advanced Filter expression
Define shortest and the fastest way to get from Canadian Museum of Nature to Canadian Museum of War.