Book Image

QGIS Python Programming Cookbook

Book Image

QGIS Python Programming Cookbook

Overview of this book

Table of Contents (16 chapters)
QGIS Python Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Performing network analysis


Network analysis allows you to find the most efficient route between two points along a defined network of connected lines. These lines might represent streets, pipes in a water system, the Internet, or any number of connected systems. Network analysis abstracts this common problem so that the same techniques and algorithms can be applied across a wide variety of applications. In this recipe, we'll use a generic line network to perform analysis using the Dijkstra algorithm, which is one of the oldest algorithms used to find the shortest path. QGIS has all of this functionality built in.

Getting ready

First, download the vector dataset from the following link, which includes two shapefiles, and unzip it to a directory named shapes in your qgis_data directory:

https://geospatialpython.googlecode.com/svn/network.zip

How to do it...

We will create a network graph by defining the beginning and end of our network of lines, and then use this graph to determine the shortest...