Book Image

Mastering QGIS - Second Edition

By : Kurt Menke, GISP, Paolo Corti, Richard Smith Jr., GISP, Luigi Pirelli, John Van Hoesen, GISP
Book Image

Mastering QGIS - Second Edition

By: Kurt Menke, GISP, Paolo Corti, Richard Smith Jr., GISP, Luigi Pirelli, John Van Hoesen, GISP

Overview of this book

QGIS is an open source solution to GIS. It is widely used by GIS professionals all over the world. It is the leading alternative to the proprietary GIS software. Although QGIS is described as intuitive, it is also by default complex. Knowing which tools to use and how to apply them is essential to producing valuable deliverables on time. Starting with a refresher on the QGIS basics, this book will take you all the way through to creating your first custom QGIS plugin. From the refresher, we will recap how to create, populate, and manage a spatial database. You’ll also walk through styling GIS data, from creating custom symbols and color ramps to using blending modes. In the next section, you will discover how to prepare vector, heat maps, and create live layer effects, labeling, and raster data for processing. You’ll also discover advanced data creation and editing techniques. The last third of the book covers the more technical aspects of QGIS such as using LAStools and GRASS GIS’s integration with the Processing Toolbox, how to automate workflows with batch processing, and how to create graphical models. Finally, you will see how to create and run Python data processing scripts and write your own QGIS plugin with pyqgis. By the end of the book, you will understand how to work with all the aspects of QGIS, and will be ready to use it for any type of GIS work.
Table of Contents (19 chapters)
Mastering QGIS - Second Edition
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

Welcome to the expanded second edition of Mastering QGIS. The goal of this book is to help intermediate and advanced users of GIS develop a deep understanding of the capabilities of QGIS, while building the technical skills that would facilitate making the shift from a proprietary GIS software package to QGIS. This edition is updated to the latest long-term release version (2.14) and includes descriptions and examples of many new features.

QGIS embodies the open source community's spirit. It seamlessly works with other free and open source geospatial software, such as SAGA, GDAL, GRASS, and LAStools, and supports standards and formats that are published by a myriad of organizations. QGIS is about freedom in the geospatial world: freedom to choose your operating system, freedom from licensing fees, freedom to customize, freedom to look under the hood, and freedom to contribute to the development of QGIS. As you work through this book, we believe that you will be amazed at how much capability and freedom QGIS provides.

QGIS has rapidly risen from the initial version written by Gary Sherman in 2002 to become a globally used and developed volunteer-led project. In 2009, QGIS version 1.0 was released as an Open Source Geospatial Foundation (OSGeo) project and continues to be rapidly adopted worldwide. The enduring support of the open source community has really delivered QGIS to a point where it is now a top-shelf product that should be in all GIS users' toolboxes, and we want this book to be your tour guide and reference as you learn, use, and contribute to QGIS.

What this book covers

Chapter 1, A Refreshing Look at QGIS, reviews the installation and basic functionality of QGIS, which will be the assumed knowledge for the remainder of the book.

Chapter 2, Creating Spatial Databases, covers how to create and edit spatial databases using QGIS. While QGIS supports many spatial databases, SpatiaLite will be used in this chapter. First, core database concepts will be covered, followed by the creation of a spatial database. Next, importing, exporting, and editing data will be covered. The chapter will conclude with queries and view creation.

Chapter 3, Styling Raster and Vector Data, covers styling raster and vector data for display. First, color selection and color ramp management are covered. Next, single-band and multi-band raster data are styled using custom color ramps and blending modes. Next, complex vector styles and vector layer rendering are covered. Rounding out the chapter is the use of diagrams to display thematic map data.

Chapter 4, Preparing Vector Data for Processing, covers techniques useful for turning raw vector data into a more usable form. The chapter will start with data massaging and modification techniques such as merging, creating indices, checking for geometry errors, and basic geoprocessing tools. Next, advanced field calculations will be covered, followed by complex spatial and aspatial queries. The chapter will end by defining new or editing existing coordinate reference systems.

Chapter 5, Preparing Raster Data for Processing, covers the preparation of raster data for further processing using the GDAL menu tools and the Processing Toolbox algorithms. Specifically, these include reclassification, resampling, rescaling, mosaics, generating pyramids, and interpolation. The chapter will conclude by converting raster to vector.

Chapter 6, Advanced Data Creation and Editing, provides advanced ways to create vector data. As there is a great deal of data in tabular format, this chapter will cover mapping coordinates and addresses from tables. Next, georeferencing of imagery into a target coordinate reference system will be covered. The final portion of the chapter will cover testing topological relationships in vector data and correcting any errors via topological editing.

Chapter 7, Advanced Data Visualization, provides advanced ways to display your analysis results. QGIS has a greatly expanded repertoire of layer styling and display options. In this chapter, you will learn how to use Live Layer Effects, utilize the inverted polygon renderer, create an Atlas in the Print Composer, and use the QGIS2ThreeJS plugin to create a 3D view of your data.

Chapter 8, The Processing Toolbox, begins with an explanation and exploration of the QGIS Processing Toolbox. Various algorithms and tools, available in the toolbox, will be used to complete common spatial analyses and geoprocessing tasks for both raster and vector formats. To illustrate how these processing tools might be applied to real-world questions, two hypothetical scenarios are illustrated by relying heavily on GRASS and SAGA tools.

Chapter 9, Automating Workflows with the Graphical Modeler, covers the purpose and use of the graphical modeler to automate analysis workflows. In the chapter, you will develop an automated tool/model that can be added to the Processing Toolbox.

Chapter 10, Creating QGIS Plugins with PyQGIS and Problem Solving, covers the foundational information required to create a Python plugin for QGIS. Information about the API and PyQGIS help will be covered first, followed by an introduction to the iface and QGis classes. Next, the steps required to create and structure a plugin will be covered. The chapter will wrap up after providing you with information on creating graphical user interfaces and setting up debugging environments to debug code easily.

Chapter 11, PyQGIS Scripting, provides topics for integrating Python analysis scripts with QGIS outside of the Processing Toolbox. Layer loading and management are first covered, followed by an exploration of the vector data structure. Next, the programmatic launching of other tools and external programs are covered. Lastly, the QGIS map canvas is covered with respect to how a script can interact with the map canvas and layers within.

What you need for this book

To get the most from this book, it is recommended that you install QGIS and follow the explanations. If you choose to do so, you will need a reasonably modern computer with access to the Internet to download and install QGIS, read the documentation, and install plugins. QGIS can run on Windows, Mac OS X, and many Linux distributions.

Who this book is for

This book is for intermediate to advanced GIS users, developers, and consultants who are familiar with QGIS but want to look deeper into the software to unleash its full potential. The reader is expected to be comfortable with common GIS functions and concepts, as possession of this knowledge is assumed throughout the book. This book focuses on how to use QGIS and its functions beyond the basics.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, and user input are shown as follows: "Either of these methods requires the use of the command line, sudo rights, and the apt-get package manager."

A block of code is set as follows:

deb        http://qgis.org/debian trusty main
deb-src    http://qgis.org.debian trusty main

Any command-line input or output is written as follows:

sudo apt-get update
sudo apt-get install qgis python-qgis

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The QGIS interface is divided into four interface types: Menu Bar, Toolbars, Panel, and Map Display."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-QGIS-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at. https://github.com/PacktPublishing/ Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MasteringQGISSecondEdition_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.