Network Analysis Plugins in QGIS, What (and How) to Use

From CUOSGwiki
Jump to navigationJump to search

Introduction and Purpose

. Network analysis is a large aspect of geomatics in which operations are run on a network composed of nodes and edges to solve a variety of problems. Typically, edges represent roads, trails, or other transportation related infrastructure while nodes represent addresses, but there are also other forms of networks like social spatial networks (SSNs). Some of the most common forms of network analysis are point-to-point routing problems like shortest path analysis and the traveling salesman problem, and service area calculations, sometimes called isochrone or iso-area generation. Closest facility searches (referred to as POI searches by the Hqgis plugin), and geocoding are two other common applications of network analysis. This page is meant to serve as a guide and a series of tutorials on several network analysis plugins in QGIS. Using this resource, you will be able to determine which plugin best suits the needs of your project and follow a step-by-step tutorial to learn how to use its tools. This tutorial is catered to those who are familiar with QGIS operations.


QGIS

Quantum GIS, commonly referred to as QGIS, is an open source software that boasts a great number of tools and functions to complete various geospatial operations. It is maintained and updated through its large volunteer community, and there are a wealth of online resources available on the QGIS site and the associated documentation page which contains resources like help manuals

QGISlogo.png

APIs

API stands for Application Programming Interface. APIs allow two softwares to communicate with each other. In this tutorial, APIs enable plugins to access different data and tools to conduct network analyses. The reason many of the plugins do not require a local data download to conduct operations (see table under Plugins) is because they are access data from an external server through an API. For more information on APIs, feel free to visit the AWS API resource page. Remember, just because you are not downloading a copy of the data does not mean you do not have to provide attribution for your data! Always cite your sources! Both the HERE and TravelTime APIs have user agreements that you consent to when you create your account. Click on the following links to view each of these agreements HERE Acceptable Use Policy, TravelTime Attribution.

Learning Outcomes

After completing this tutorial, you will know how to:

  • Install a plugin on QGIS
  • Register for HERE and TravelTalk APIs
  • Conduct Point-to-point network analysis using QNEAT3, Online Routing Mapper, TravelTime, and Hqgis
  • Do Service Area calculations with QNEAT3, TravelTime, and Hqgis
  • Geocode addresses using TravelTime and Hqgis
  • Run a POI search with Hqgis


Plugins

Several plugins have been created to support or enhance the functionality of QGIS. Each plugin has different benefits and limitations, so be sure to familiarize yourself with your project to make sure you make the right selection. For example, using an API may be preferred to reduce processing times as calculations are being completed on external servers. On the other hand, you will have to plan ahead to use APIs that require accounts to generate permission keys, as it can take some time for your account to gain access. The table below shows the different functions each plugin offers to help with your selection. For more information on a particular plugin, click the embedded link.

Plugin Local Data Required? Functions API Login required? Outputs Notes
QNEAT3 Yes Point-to-point routing, Service Area calculation, Origin-Destination matrix No Savable temporary layer with attribute table displaying either network cost breakdown for shortest path, or cost classes for iso-areas Origin-Destination matrix does not generate
Online Routing Mapper No Point-to-point routing No Savable temporary layer with blank attribute table Only HERE and TomTom APIs remain supported
TravelTime No Point-to-point routing, Service Area calculation, Geocoding Yes N/A Slow API account validation, limited number of data queries on free account
Hqgis No Point-to-point routing, Service Area calculation, Geocoding, POI search Yes Savable temporary layer with attribute table displaying either route length and time for shortest path, or cost limit for iso-areas Limited number of API keys generated for each project

Tutorial

Setting up your project

Before you start your project, there are some important first steps that must be taken. As with all GIS projects, it is strongly recommended to have a project folder to store all your data and project files. If you do not have QGIS installed and/or do not know how to install plugins, those processes are detailed below. If you are familiar with these processes and have already completed them at this point, feel free to continue to the Tutorial section of this guide.

QGIS

  • This tutorial uses QGIS, if you have yet to install the software, follow this link to do so. This tutorial uses QGIS 3.32.
  • Select the version you wish to download based on your operating system, and follow the guide that is installed in the package.
  • Once QGIS is installed, launch the application.
  • Don't forget to set your coordinate system to one that is appropriate to your area of interest. This tutorial uses NAD83 MTM Zone 8 as the area of interest is the city of Trois-Rivières.
  • With that completed, you are ready to begin the tutorial.

Installing Plugins

There are many plugins available in QGIS, but they must be installed before you can use them.

  • To access plugins, click the Plugins tab in the menu, then select Manage and Install Plugins... This will open a pop-up window.
Plugin tab.png
  • At the top of the new window, you will see a search bar (highlighted in yellow), and a list of all available plugins below it.
Plugin window1.png
  • Search for QNEAT3 using the search bar, and select the result. A brief description will appear in the right hand side of the window. Next, click the Install Plugin button (highlighted in yellow) to install.
Plugin window2.png
  • Repeat this process for the Online Routing Mapper, TravelTime, and Hqgis plugins.


QNEAT3

QNEAT3 is similar to the default network analysis tools in QGIS, as both are able to do point-to-point routing, do service area calculations, and require a network file to either of these analyses. However, QNEAT3 offers a different visualization of the outputs, with routes extending off the network if the start or end point lies outside the network, and showing service areas as either contours, polygons, pointclouds, or buffers, while the default QGIS tool depicts the service area by highlighted network segments within the area.

Data

The data used in this tutorial is the Trois-Rivières road network found using the Government of Canada's Open Government Portal by searching for "road network". It can be found and downloaded by following this link and selecting the SHP file option.

GC Portak.png
  • Extract the downloaded .zip file into your project folder and load the data into QGIS.

Point-to-point routing

  • To access QNEAT's tools, click on the gear (Toolbox) icon in the top right corner of your QGIS window (marked in red). This will open the Processing Toolbox tab on the left side of your screen.
Tb 1.png
  • In the Processing Toolbox search bar, type "QNEAT3". Click on the drop-down arrow next to the result (highlighted in yellow) to see all of the tools available with the plugin.
Tb 2.png
  • Under Routing, double click on Shortest path (point to point) to open a pop-up window.
  • Ensure that the Trois-Rivières road network is selected as your Network Layer (shown in yellow). To select your Start and End points, click on the three dots (shown in red). These will allow you to use your mouse to browse the area, simply select your points by clicking on the desired location.
QNEAT sp.png
  • Once this is complete, hit Run in the bottom right corner and wait for the operation to complete.
  • The output will be a line that connects the two selected points that follows the network, though it may start or end off the network if the points lie off-network.
QNEAT sp2.png

Service Area calculation

  • For Service Area calculation using QNEAT3, follow the first three steps listed under Point-to-point routing, but double click on Iso-Areas as Contours (from Point) instead of Shortest path
  • In the pop-up window, ensure that the Trois-Rivières road network is selected as your Network Layer (shown in yellow). To select your Start point, click on the three dots (shown in red). This will allow you to use your mouse to browse the area, simply select your point by clicking on the desired location.
QN sa1.png
  • Under Optimization Criterion, select either Shortest Path or Fastest Path. This will determine whether your service area will be defined by travel time or travel distance.
  • Once this is complete, set the Size of Iso-Area. This determines the total size of the area and is expressed in cost units. In this tutorial, the default of 2500 distance cost units was used.
  • Use the contour interval to determine the size of division of the Iso-Area. If you want to communicate what distance can be reached in 5, 10, and 30 minutes of driving, you would do that here. The default of 500 distance cost units was used for this tutorial.
  • When you have filled in all your inputs, click Run in the bottom right corner and wait for the operation to complete.
  • The output will be a layer of lines delineating the extent of each cost interval and an interpolated raster layer that shows the cost of network travel at each location.
QN sa2.png

Saving your layers

The outputs of this plugin are temporary layers that will not be saved if you close your project. If you are unfamiliar with how to save temporary layers in QGIS, go to the Saving your layers section at the bottom of the page.

Online Routing Mapper

Online Routing Mapper uses several APIs to conduct point-to-point routing, making it very useful for quick but simple analyses. Unfortunately several APIs no longer seem to be supported by the plugin or require additional registration to use, meaning that only the TomTom and HERE routing APIs currently generate results. Please note that the OSM basemap from the QuickMapServices was used to help visualize the outputs in this tutorial.

Point-to-point routing

  • When you install the Online Routing Mapper plugin in QGIS, it automatically adds a button your page for quick access. It resembles a green cloud adorned with arrows, and can be found in the top right corner.
ORM 1.png
  • To open the tool, click on the icon. A pop-up window will appear with an Online Service drop-down menu. This is where you select the API you will be using. The TomTom API was used in this tutorial
  • Select your start and end points by click on each Choose button. This will allow you to use your mouse to browse the area, simply select your points by clicking on the desired location.
ORM 2.png
  • With all your inputs selected, hit the Run button. A dialog window will appear saying "The analysis result was added to the canvas." Close this and the Online Routing Mapper window to view the generated route.
  • The output will appear as black and white line connecting the green starting point to the red end point.
ORM 3.png

Saving your layers

The outputs of this plugin are temporary layers that will not be saved if you close your project. If you are unfamiliar with how to save temporary layers in QGIS, go to the Saving your layers section at the bottom of the page.

TravelTime

API login

  • Visit the sign up page at TravelTime.com
  • Fill out the form under the Get started with TravelTime API header.
TT API.png
  • You will be redirected to your account page and must wait for your account to be validated.

Point-to-point routing

Service Area calculation

Geocoding

Hqgis

Hqgis is the most robust of all the API plugins, offering four network analysis functions: point-to-point routing, service area calculation, geocoding, and a function they call POI search, which allows you to find where the nearest POIs (fire station, for example) to the entered address are and displays their location. The plugin enables access to the HERE API, which requires an account to use. Please note that the OSM basemap from the QuickMapServices was used to help visualize the outputs in this tutorial.

API login

HQ 1.png
  • In the Hqgis pop-up window, select the Credentials tab. Paste your API key into the bar and click save credentials. You should now be connected through the HERE API.
Hq 2.png

Point-to-point routing

  • Open the Hqgis window, as shown in step 2 of the API login, and select the Routing tab.
Hq r.png
  • The To and From Addresses must be input manually, meaning that you must enter the street address of your start and end points.
  • Select time or distance as your cost unit using the Type drop-down. Fast is used as the time cost, and short is used as the distance cost.
  • The travel mode allows for the selection of different route options (pedestrians can use sidewalks while cars and trucks cannot). Car was the selected option for this tutorial
  • Traffic can be enabled or disabled and uses historical data, but was not used in this tutorial. If traffic is enabled, you are also able to set a departure time.
  • Click Calculate Route at the bottom of the window to generate the shortest path.
  • The output is a line connecting the start and end points.
Hq r2.png

Service Area calculation

  • Open the Hqgis window, as shown in step 2 of the API login, and select the Isochrone tab.
Hq I1.png
  • The From Address must be input manually, meaning that you must enter the street address of your start point.
  • Select time or distance as your cost unit using the Metric drop-down. Distance was used in this tutorial.
  • The travel mode allows for the selection of different route options (pedestrians can use sidewalks while cars and trucks cannot). Car was the selected option for this tutorial.
  • Traffic can be enabled or disabled and uses historical data, but was not used in this tutorial. If traffic is enabled, you are also able to set a departure time.
  • Click Calculate Isochrones at the bottom of the window to generate the Service Area.
  • The output will be a polygon covering the extent of the service area.
Hq i2.png

Geocoding

Geocoding with Hqgis allows you to: Create single points by inputting a street address, create points from an input table with an address field, or create points from an input table with multiple separate address fields (country, state, county, postal code, city, street, house number). All of these functions create the same outputs, which option you select depends on the format of your inputs. This tutorial will demonstrate how to create a single point from a street address input.

  • Open the Hqgis window, as shown in step 2 of the API login, and select the Geocode tab.
Hq g1.png
  • Type the street address of your intended location in the Address bar
  • Click Geocode Single Address to generate your point
  • Your output will be a single point feature (symbolized by the red dot) with detailed address information in its attributes, including the country, state (province), city, street and postal code.
Hq g2.png

POI Search

  • Open the Hqgis window, as shown in step 2 of the API login, and select the POI Search tab.
Hq p1.png
  • Type the street address of your intended location in the From Address bar.
  • Select the type(s) of POI that you are looking for. Note that you can select multiple types, but the tool will generate a maximum of 100 points and select the 100 closest POIs, regardless of types. In the tutorial, Police-Fire-Emergency and Post office were selected.
  • Click Find POIs at the bottom of the screen to generate your points.
  • Your output will consist of multiple points distributed around your From Address. Note that there is not a point generated for the From Address.
Hq p2.png

Saving your layers

The outputs of this plugin are temporary layers that will not be saved if you close your project. If you are unfamiliar with how to save temporary layers in QGIS, go to the Saving your layers section at the bottom of the page.

Saving your Layers

  • To save your temporary output layer, right click on the layer, hover over Export, and click Save Features As...
Save 1.png
  • In the pop-up window, select the desired file format from the Format drop-down list.
Save 2.png
  • Provide your layer with an appropriate name, and click on the 3 dots to browse your directory and save the file in your project folder.
  • Set the desired coordinate system from the CRS drop-down.
  • Under Encoding, you can select which fields to include or drop in your new saved file. In this example, all fields were included.
  • Click OK in the bottom right to save your layer as a new file.

Resources

Amazon Web Services. (n.d.) What is an API (Application Programming Interface)?. Retrieved December 1, 2023 from https://aws.amazon.com/what-is/api/#:~:text=API%20stands%20for%20Application%20Programming,other%20using%20requests%20and%20responses.

Government of Canada. (n.d.). Open Government Portal. Retrieved November 18, 2023 from https://search.open.canada.ca/opendata/

Government and Municipalities of Québec. (2023). Road Network. Retrieved November 20, 2023, from https://open.canada.ca/data/en/dataset/17e9938c-c744-4171-b7bc-53abd7a6d8bc

Raffler, Clemens. (2018). QNEAT3 QGIS Network Analysis Toolbox 3. Retrieved October 12, 2023, from https://root676.github.io/

Selim, Mehmet. (2018). Online Routing Mapper. Retrieved October 12, 2023, from https://cbsuygulama.wordpress.com/online-routing-mapper-en/

TravelTime. (n.d.). Reference manual. Retrieved October 12, 2023, from https://docs.traveltime.com/qgis/about/reference-manual

TravelTime. (n.d.). Attribution. Retrieved December 2, 2023, from https://docs.traveltime.com/api/overview/attribution

Klinger, Riccardo. (n.d.). Hqgis. Retrieved October 12, 2023, from https://github.com/riccardoklinger/Hqgis/blob/master/readme.md

HERE (2023). How to get HERE Developer Credentials and API Keys. Retrieved November 21, 2023, from https://www.here.com/docs/bundle/getting-here-credentials/page/README.html

HERE (2022). HERE Acceptable Use Policy. Retrieved December 2, 2023, from https://legal.here.com/en-gb/terms/acceptable-use-policy

QGIS (n.d.). QGIS Documentation. Retrieved November 22, 2023, from https://qgis.org/en/docs/index.html