Book Image

QGIS Python Programming Cookbook, Second Edition - Second Edition

By : Joel Lawhead
Book Image

QGIS Python Programming Cookbook, Second Edition - Second Edition

By: Joel Lawhead

Overview of this book

QGIS is a desktop geographic information system that facilitates data viewing, editing, and analysis. Paired with the most efficient scripting language—Python, we can write effective scripts that extend the core functionality of QGIS. Based on version QGIS 2.18, this book will teach you how to write Python code that works with spatial data to automate geoprocessing tasks in QGIS. It will cover topics such as querying and editing vector data and using raster data. You will also learn to create, edit, and optimize a vector layer for faster queries, reproject a vector layer, reduce the number of vertices in a vector layer without losing critical data, and convert a raster to a vector. Following this, you will work through recipes that will help you compose static maps, create heavily customized maps, and add specialized labels and annotations. As well as this, we’ll also share a few tips and tricks based on different aspects of QGIS.
Table of Contents (16 chapters)
QGIS Python Programming Cookbook - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Routing along streets


Sometimes, you may want to find the best driving route between two addresses. Street routing has now become so commonplace that we take it for granted. However, if you explore the recipes on geocoding and network analysis in this book, you will begin to see what a complex challenge street routing truly is. To perform routing operations in QGIS, we'll use the QGIS GeoSearch plugin, which is written in Python, so that we can access it from the console.

Getting ready

You will need to install the QGIS Python GeoSearch plugin for this exercise in order to do the routing as well as the QGIS OpenLayers plugin to overlay the result on a Google map, as follows:

  1. From the QGIS Plugins menu, select Manage and Install Plugins....

  2. If you have the QGIS GeoCoding plugin installed, then you must uninstall it, as sometimes it conflicts with the GeoSearch plugin. So, select this in the plugins' list and click on the Uninstall plugin button.

  3. In the Plugins dialog search box, search for GeoSearch...