Book Image

Learning QGIS - Third Edition

By : Anita Graser
Book Image

Learning QGIS - Third Edition

By: Anita Graser

Overview of this book

QGIS is a user-friendly open source geographic information system (GIS) that runs on Linux, Unix, Mac OS X, and Windows. The popularity of open source geographic information systems and QGIS in particular has been growing rapidly over the last few years. Learning QGIS Third Edition is a practical, hands-on guide updated for QGIS 2.14 that provides you with clear, step-by-step exercises to help you apply your GIS knowledge to QGIS. Through clear, practical exercises, this book will introduce you to working with QGIS quickly and painlessly. This book takes you from installing and configuring QGIS to handling spatial data to creating great maps. You will learn how to load and visualize existing spatial data and create data from scratch. You will get to know important plugins, perform common geoprocessing and spatial analysis tasks and automate them with Processing. We will cover how to achieve great cartographic output and print maps. Finally, you will learn how to extend QGIS using Python and even create your own plugin.
Table of Contents (13 chapters)
Learning QGIS Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating custom geoprocessing scripts using Python


In Chapter 4, Spatial Analysis, we used the tools of Processing Toolbox to analyze our data, but we are not limited to these tools. We can expand processing with our own scripts. The advantages of processing scripts over normal Python scripts, such as the ones we saw in the previous section, are as follows:

  • Processing automatically generates a graphical user interface for the script to configure the script parameters

  • Processing scripts can be used in Graphical modeler to create geoprocessing models

As the following screenshot shows, the Scripts section is initially empty, except for some Tools to add and create new scripts:

Writing your first Processing script

We will create our first simple script; which fetches some layer information. To get started, double-click on the Create new script entry in Scripts | Tools. This opens an empty Script editor dialog. The following screenshot shows the Script editor with a short script that prints the input...