Mastering QGIS - Second Edition - Kurt Menke GISP - E-Book

Mastering QGIS - Second Edition E-Book

Kurt Menke GISP

0,0
46,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Go beyond the basics and unleash the full power of QGIS with practical, step-by-step examples

About This Book

  • This book is your one-stop solution to all of your GIS needs using the open source QGIS
  • Master QGIS by learning about database integration, geoprocessing tools, Python scripts, advanced cartography, and custom plugins
  • This example-rich, practical guide will help you create sophisticated analyses and maps

Who This Book Is For

If you are a GIS professional, a consultant, a student, or perhaps a fast learner who wants to go beyond the basics of QGIS, then this book is for you. It will prepare you to realize the full potential of QGIS.

What You Will Learn

  • Create and manage a spatial database
  • Get to know advanced techniques to style GIS data
  • Prepare both vector and raster data for processing
  • Add heat maps, live layer effects, and labels to your maps
  • Master LAStools and GRASS integration with the Processing Toolbox
  • Edit and repair topological data errors
  • Automate workflows with batch processing and the QGIS Graphical Modeler
  • Integrate Python scripting into your data processing workflows
  • Develop your own QGIS plugin

In Detail

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.

Style and approach

This step-by-step comprehensive guide will let you dig your teeth into working with spatial databases, creating your own QGIS plugins, and creating your own custom graphical models.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 502

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Mastering QGIS - Second Edition
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. A Refreshing Look at QGIS
Release schedules
QGIS download and installation
Installing QGIS on Windows
Installing QGIS on Mac OS X
Installing QGIS on Ubuntu Linux
Installing QGIS only
Installing QGIS and other FOSSGIS packages
Installing QGIS on a Chromebook
Tour of QGIS
Familiarizing yourself with QGIS Desktop
User interface themes
Familiarizing yourself with QGIS Browser
Loading data into QGIS Desktop
Loading vector data
Loading raster data
Loading databases
Loading web services
Working with CRS
Working with tables
Creating table joins
Editing data
Snapping
Styling vector data
Styling raster data
Enhancing raster display with contrast enhancement
Blending modes
Composing maps
Adding functionality with plugins
Custom QGIS variables
Using Project level variables in the Print Composer
Using variables in data defined overrides
Using Layer level variables
Summary
2. Creating Spatial Databases
Fundamental database concepts
Describing database tables
Knowing about table relationships
Reviewing the basics of Structured Query Language
Creating a spatial database
Importing data into a SpatiaLite database
Importing KML into SpatiaLite
Importing a shapefile into SpatiaLite
Importing tables into SpatiaLite
Exporting tables out of SpatiaLite
Managing tables
Creating a new table
Renaming a table
Editing table properties
Deleting a table
Emptying a table
Creating queries and views
Creating a SQL query
Creating a spatial view
Dropping a spatial view
Summary
3. Styling Raster and Vector Data
Choosing and managing colors
Always-available color picker components
Changeable panels in color picker
Color ramp
Color wheel
Color swatches
Color sampler
Color picker components available in the Layers panel
Managing color ramps
Managing the QGIS color ramp collection
Renaming a color ramp
Removing a color ramp
Exporting a color ramp
Importing a color ramp
Adding a color ramp
Adding a Gradient color ramp
Adding a Random color ramp
Adding a ColorBrewer color ramp
Adding a cpt-city color ramp
Editing a color ramp
Styling singleband rasters
Paletted raster band rendering
Singleband gray raster band rendering
Singleband pseudocolor raster band rendering
Styling multiband rasters
Creating a raster composite
Raster color rendering
Raster resampling
Styling vectors
Single-symbol vector styling
Categorized vector styling
Graduated vector styling
Rule-based vector styling
Point-displacement vector styling
Inverted polygons vector styling
Heatmap vector styling
2.5 D vector styling
Vector layer rendering
Layer transparency
Layer blending mode
Feature blending mode
Control feature rendering order
Using diagrams to display thematic data
Parameters common to all diagram types
Diagram size parameters
Diagram placement parameters
Adding attributes to diagrams
Creating a pie chart diagram
Creating a text diagram
Creating a histogram chart diagram
Saving, loading, and setting default styles
Saving a style
Loading a style
Setting and restoring a default style
Adding and renaming styles in the current QGIS project
Summary
4. Preparing Vector Data for Processing
Merging shapefiles
Creating spatial indices
Checking for geometry errors
Check Geometries plugin
Converting vector geometries
Creating polygon centroids
Converting polygons to lines and lines to polygons
Creating polygons surrounding individual points
Extracting nodes from lines and polygons
Simplifying and densifying features
Converting between multipart and singlepart features
Adding geometry columns to an attribute table
Using basic vector geoprocessing tools
Spatial overlay tools
Using the Clip and Difference tools
Using the Intersect and Symmetrical Difference tools
Overlaying polygon layers with Union
Creating buffers
Generating convex hulls
Dissolving features
Defining coordinate reference systems
Understanding the PROJ.4 definition format
Defining a new custom coordinate reference system
Viewing a statistical summary of vector layers
Advanced field calculations
Exploring the field calculator interface
Writing advanced field calculations
The first example – calculating and formatting current date
The second example – calculating with geometry
The third example – calculating a population-dependent label string
Conditional formatting for attribute table cells
Complex spatial and aspatial queries
Summary
5. Preparing Raster Data for Processing
Reclassifying rasters for analysis
Using the Slicer plugin
Converting datasets from floating point to integer rasters
Resampling rasters for analysis
Rescaling raster values
Aligning raster pixels
Creating a raster mosaic
Generating raster overviews (pyramids)
Converting between raster and vector data models
Converting from raster to vector
Converting from vector to raster (rasterize)
Creating raster surfaces via interpolation
Summary
6. Advanced Data Creation and Editing
Creating points from coordinate data
Mapping well-known text representations of geometry
Geocoding address-based data
How address geocoding works
The first example – geocoding using web services
The second example – geocoding using local street network data
Georeferencing imagery
Understanding ground control points
Using the Georeferencer GDAL plugin
The first example – georeferencing using a second dataset
Getting started
Entering ground control points
Transformation settings
Completing the operation
The second example – georeferencing using a point file
Checking the topology of vector data
Installing the topology checker
Topological rules
Rules for point features
Rules for line features
Rules for polygon features
Using the topology checker
Repairing topological errors via topological editing
Example 1 – resolving duplicate geometries
Example 2 – repairing overlaps
Setting the editing parameters
Repairing an overlap between polygons
Example 3 – repairing a gap between polygons
Summary
7. Advanced Data Visualization
Learn to use live layer effects
Creating beautiful effects with inverted polygon shapeburst fills
Creating coastal vignettes
Study area mask
Creating 3D views with QGIS2ThreeJS
Creating 3D views of terrain
Extruding features
Creating an Atlas
Basic Atlas configuration
Dynamic titles
Dynamic legends
Highlighting the coverage feature
Summary
8. The Processing Toolbox
About the Processing Toolbox
Configuring the Processing Toolbox
Understanding the Processing Toolbox
Using the Processing Toolbox
Performing raster analyses with GRASS
Calculating shaded relief
Calculating the least-cost path
Calculating the slope using r.slope
Reclassifying the new slope raster and the land use raster
Combining the reclassified slope and land use layers
Calculating the cumulative cost raster using r.cost
Calculating the cost path using LCP
Evaluating a viewshed
Clipping the elevation to the boundary of the park using GDAL
Calculating viewsheds for towers using r.viewshed
Combining viewsheds using r.mapcalculator
Calculating raster statistics using r.stats
SAGA
Evaluating a habitat
Calculating elevation ranges using the SAGA Raster calculator
Clipping land use to the park boundary using Clip grid with polygon
Querying land use for only surface water using SAGA Raster calculator
Finding proximity to surface water using GDAL Proximity
Querying the proximity for 1,000 meters of water using GDAL Raster calculator
Reclassifying land use using the Reclassify grid values tool
Combining raster layers using SAGA Raster calculator
Exploring hydrologic analyses with TauDEM
Removing pits from the DEM
Calculating flow directions across the landscape
Calculating the upstream area above Fort Klamath
Calculating a stream network raster grid
Creating a watershed-specific vector stream network
R
Exploring summary statistics and histograms
LAStools and Fusion
Exploring LIDAR data
Converting LAS/LAZ files
Creating surfaces from LIDAR data
Summary
9. Automating Workflows with the Graphical Modeler
An introduction to the graphical modeler
Opening the graphical modeler
Configuring the modeler and naming a model
Adding data inputs to your model
Adding algorithms to your model
Running a model
Editing a model
Documenting a model
Saving, loading, and exporting models
Executing model algorithms iteratively
Nesting models
Using batch processing with models
Converting a model into a Python script
Summary
10. Creating QGIS Plugins with PyQGIS and Problem Solving
Webography – where to get API information and PyQGIS help
PyQGIS cookbook
API documentation
The QGIS community, mailing lists, and IRC channel
Mailing lists
IRC channel
The Stack Exchange community
Sharing your knowledge and reporting issues
The Python Console
Getting sample data
My first PyQGIS code snippet
My second PyQGIS code snippet – looping the layer features
Exploring iface and QGis
Exploring a QGIS API in the Python Console
Creating a plugin structure with Plugin Builder
Installing Plugin Builder
Locating plugins
Creating my first Python plugin – TestPlugin
Setting mandatory plugin parameters
Setting optional plugin parameters
Generating the plugin code
Compiling the icon resource
Plugin file structure – where and what to customize
Exploring main plugin files
Plugin Builder-generated files
A simple plugin example
Adding basic logic to TestPlugin
Modifying the layout with Qt Designer
Adding two pull-down menus
Modifying GUI logic
Modifying plugin logic
Classifying layers
Populating the combobox
Understanding self
Showing and running the dialog
Some improvements
More detail of the code
Setting up a debugging environment
What is a debugger?
Installing Aptana
Setting up PYTHONPATH
Starting the Pydevd server
Connecting QGIS to the Pydevd server
Connecting using the Remote Debug QGIS plugin
Debugging session example
Creating a PyDev project for TestPlugin
Adding breakpoints
Debugging in action
Summary
11. PyQGIS Scripting
Where to learn Python basics
Tabs or spaces, make your choice!
How to load layers
How to manage rasters
Exploring QgsRasterLayer
Visualizing the layer
Managing vector files
Managing database vectors
Vector structure
The basic vector methods
Describing the vector structure
Describing the header
Describing the rows
Exploring QgsGeometry
Iterating over features
Describing the iterators
Editing features
Updating canvas and symbology
Editing through QgsVectorDataProvider
Changing a feature's geometry
Changing a feature's attributes
Deleting a feature
Adding a feature
Editing using QgsVectorLayer
Discovering the QgsVectorLayerEditBuffer class
Changing a feature's geometry
Changing a feature's attributes
Adding and removing a feature
Running Processing Toolbox algorithms
Looking for an algorithm
Getting algorithm information
Running algorithms from the console
Running your own processing script
Creating a test Processing Toolbox script
Looking at the custom script
Running the script
Running an external algorithm or command
Running a simple command
Interacting with the map canvas
Getting the map canvas
Explaining Map Tools
Setting the current Map Tool
Getting point-click values
Getting current Map Tool
Creating the new Map Tool
Creating a map canvas event handler
Creating a Map Tool event handler
Setting up the new Map Tool
Using point-click values
Exploring the QgsRubberBand class
Summary
Index

Mastering QGIS - Second Edition

Mastering QGIS - Second Edition

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: March 2015

Second edition: September 2016

Production reference: 1270916

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78646-037-0

www.packtpub.com

Credits

Authors

Kurt Menke, GISP

Dr. Richard Smith Jr., GISP

Dr. Luigi Pirelli

Dr. John Van Hoesen, GISP

Reviewer

Paolo Corti

Commissioning Editor

Veena Pagare

Acquisition Editor

Vinay Argekar

Content Development Editor

Aishwarya Pandere

Technical Editor

Suwarna Patil

Copy Editors

Vikrant Phadke

Safis Editing

Project Coordinator

Nidhi Joshi

Proofreader

Safis Editing

Indexer

Mariammal Chettiyar

Graphics

Disha Haria

Production Coordinator

Nilesh Mohite

Cover Work

Nilesh Mohite

Foreword

Since the QGIS project was started in 2002 by Gary Sherman, the project has done what many people would have thought to be impossible—provide a viable alternative to the incumbent de facto GIS applications that is free, open source, and accessible to everyone on this planet who owns a computer. One of the joys of contributing to and participating in the QGIS project has been watching how the community of people and the body of knowledge have grown up around the project. There are few better examples of this than the work Kurt, Rick, John, and Luigi (the four co-authors of this book) have put into Mastering QGIS.

Writing a book about QGIS is no easy task, partly because of the sheer depth of functionality that QGIS offers, and partly because of the fact that QGIS is rapidly evolving. In creating this second edition of Mastering QGIS, the authors have added some great new content to cover some of the important new functionality that has been added to QGIS. They have also revised the existing content to ensure thay everything is still fresh and relevant to QGIS 2.14.

Having such an in-depth book about QGIS really lowers the barrier of entry to learning, and mastering, QGIS. I am looking forward to the day when GIS is used as commonly and routinely as a spreadsheet or a word processor. Being able to visualize and analyze the world around us is the most basic necessity if we are to promote good stewardship of the earth, responsible decision making, and humane and equitable conditions for the people that inhabit the earth. QGIS is a key element in this equation—being free and open source software really does make QGIS something that can be used by anyone on this planet who has access to a computer. Mastering QGIS provides a fantastic resource for those who wish to take full advantage of the opportunity offered by QGIS by having someone to guide them in their learning endeavors.

As you delve deeper into the world of QGIS and all the great things that the authors have to show you, take a moment to join our community (http://qgis.org), or start your own local community in your country. We welcome your participation and contribution of ideas, bug reports, code, and documentation, and we welcome you to the diverse and ever-growing group of people all around the world who are using QGIS to make the world a better place!

Happy QGISing!

Tim Sutton,

QGIS Project Chairman

About the Authors

A former archaeologist, Kurt Menke, GISP is based out of Albuquerque, New Mexico, USA. He received a master's degree in geography from the University of New Mexico in 2000. That same year, he founded Bird's Eye View (http://www.BirdsEyeViewGIS.com) to apply his expertise with GIS technology towards ecological conservation. Along with conservation, his other focus areas are public health and education.

He is an avid open source GIS proponent since he began writing MapServer applications in 2002. He has used QGIS since 2007. Recently he also authored Discover QGIS for Locate Press. In 2015, Kurt was honored to be voted in as an OsGeo Charter Member. He is an experienced FOSS4G educator and a co-author of the GeoAcademy. In 2015 he was awarded the Global Educator of the Year Team Award by GeoForAll as part of the GeoAcademy team. Kurt authors an award winning blog on FOSS4G technologies and their use in community health mapping (http://communityhealthmaps.nlm.nih.gov/).

Special thanks go to the QGIS development team and the QGIS community for their continued dedication and work that makes QGIS what it is. I would like to thank all my co-authors for being such a joy to work with. I'd also like to acknowledge Karl Benedict for originally introducing me to the world of FOSS4G and Jeffery Cavner for his ongoing camaraderie. Finally I'd like to thank my beautiful wife, Sarah, for her steady support and encouragement.

Dr. Richard Smith Jr., GISP is an assistant professor of geographic information science in the School of Engineering and Computing Sciences at Texas A&M University – Corpus Christi. He has a PhD in geography from the University of Georgia and holds a master of science in computer science and a bachelor of science in geographic information science from Texas A&M University – Corpus Christi. Richard actively researches in cartography, systems integration, and the use of geospatial technology for disaster response. He is an advocate for FOSS4G and building FOSS4G curriculum. He is also one of the co-authors of the FOSS4G Academy (http://foss4geo.org).

He has collaborated with other writers in his field, but Mastering QGIS is his first book effort.

I would like to thank my wife and daughter for putting up with my late-night and weekend writing sessions. I would also like to thank my co-author Kurt Menke for being patient with my edits.

Outside those directly involved or affected by the writing of the book, I'd like to thank my academic and life mentors Dr. Stacey Lyle, Dr. Thomas Hodler, Dr. Gary Jeffress, and Dr. Robin Murphy for providing support and well-wishes as I work through the beginnings of my career. In addition to teaching me more than you know, you have inspired me to have the confidence to teach and write. To those of you reading this, I hope I do my mentors justice by providing a clear and useful text to assist you in Mastering QGIS.

Dr. Luigi Pirelli is a freelance software analyst and developer with a degree with honors in computer science at Bari University.

He worked for 15 years in the Satellite Ground Segment and Direct Ingestion for the European Space Agency. Since 2006, he has been involved in the GFOSS world, contributing in QGIS, GRASS, and Mapserver core, and developing and maintaining many QGIS plugins. He actively participates in QGIS Hackmeetings.

Luigi is the founder of the OSGEO Italian local GFOSS chapter. Now, he lives in Spain contributing to this GFOSS community. During the last few years, he started teaching PyQGIS, organizing training from basic to advanced level, and supporting companies to develop their specific QGIS plugins.

He is also the founder the local hackerspace group Bricolabs.cc, focused on open hardware. He likes cycling, repairing everything, and training groups on conflict resolution. Other than this book, he has also contributed to the Lonely Planet guide Cycling Italy.

A special thanks to the QGIS developer community and core developers because the project is managed in a really open way, allowing contribution from everyone.

I want to thank everyone I worked with. From every one of them I learned, and without them, I wouldn't be here making my contributions to free software and this book.

Special thanks to my friends and neighbors who helped me with my son during writing this pages.

I would like to dedicate this book to my partner and especially to my son for the patience he had seeing me hours sitting in front of a computer without playing with him.

Dr. John Van Hoesen, GISP is an associate professor of geology and environmental studies at Green Mountain College in rural west-central Vermont, USA. He earned an MS and a PhD in geology from the University of Nevada, Las Vegas, in 2000 and 2003. He is a certified GIS Professional (GISP) with a broad background in the geosciences and has used some flavor of GIS to evaluate and explore geological processes and environmental issues since 1997. John has used and taught some variants of FOSS GIS since 2003 and over the last three years has taught graduate, undergraduate, and continuing education courses using only FOSS GIS software.

About the Reviewer

Paolo Corti is an environmental engineer based in Cambridge, USA. He has more than 15 years of experience in the GIS field. After working with proprietary solutions for some years, he proudly moved to open source technologies and Python since almost a decade.

He is a Geospatial Engineer Fellow at the Center for Geographic Analysis of the University of Harvard. In the past, he has worked as a software architect, developer and analyst for organizations such as UN World Food Programme, EU Joint Research Centre, World Bank, and the Italian government.

He is an OSGeo Charter member and a member of the pycsw and GeoNode Project Steering Committees. He is the co-author of PostGIS Cookbook by Packt, and writes a popular blog on open source geospatial technologies at http://www.paolocorti.net.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

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 updatesudo 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 <[email protected]>, 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:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.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 WindowsZipeg / iZip / UnRarX for Mac7-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 <[email protected]> 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 <[email protected]>, and we will do our best to address the problem.

Chapter 1. A Refreshing Look at QGIS

You are probably anxious to get started using QGIS. In this chapter, we will review the basic functionality of QGIS, which will be assumed knowledge for the remaining chapters in this book. If you need a refresher on QGIS or a quick-start guide to QGIS, you should read this chapter. The topics we will cover in this chapter are as follows:

Downloading QGIS and its installationThe QGIS graphical user interfaceLoading dataWorking with coordinate reference systems (CRS)Working with tablesEditing dataStyling dataComposing a mapFinding and installing plugins

QGIS is a volunteer-led development project licensed under the GNU General Public License. It was started by Gary Sherman in 2002. The project was incubated with the Open Source Geospatial Foundation (OSGeo) in 2007. Version 1.0 was released in 2009. The continued development of QGIS is supported by an active and vibrant community from around the world. Many people assume that they can only help with the development of QGIS if they can perform computer programming, but this is false! QGIS has many community members that write documentation, test the program for bugs, translate documents, answer forum questions, and provide financial support. It is easy to get involved, and the authors encourage you to consider contributing. Learn about how to get involved at http://qgis.org/en/site/getinvolved/.

Release schedules

Currently, a new version of QGIS is released every four months. The version released each spring is designated as a long-term release (LTR). This means it will be supported for one calendar year. Each quarter, a new stable version is released and bug fixes applied to the LTR. The LTR is recommended for production environments since it has a slower release cycle. At the time of writing this book, QGIS 2.14 is the stable version and is also the current LTR.

Tip

It is possible to have multiple versions of QGIS installed on a single machine.

QGIS download and installation

QGIS can be installed on Windows, Mac OS X, Unix, Linux, and Android operating systems, making it a very flexible software package. Both the binary installers and source code can be downloaded from download.qgis.org. In this section, we will briefly cover how to install QGIS on Windows, Mac OS X, and Ubuntu Linux. For the most up-to-date installation instructions, refer to the QGIS website.

Installing QGIS on Windows

For Windows, there are two installation options, which are as follows:

QGIS Standalone Installer: The standalone installer installs the binary version of QGIS and the Geographic Resource Analysis Support System (GRASS) using a standard Windows installation tool. You should choose this option if you want an easy installation experience of QGIS.OSGeo4W Network Installer: This provides you with the opportunity to download either the binary or source code version of QGIS, as well as experimental releases of QGIS. Additionally, the OSGeo4W installer allows you to install other open source tools and their dependencies.

Installing QGIS on Mac OS X

Follow these steps to install QGIS on a Mac:

As an initial step, it is often necessary to change your Mac security preferences to Allow apps downloaded from: Anywhere.The Mac QGIS installation files are available from http://www.kyngchaos.com/software/qgis.Download and install the GDAL Complete 1.11 framework package.Download and install NumPy: http://www.kyngchaos.com/software/python.Download and install the Matplotlib Python module.Download and install the QGIS Mac OSX Installer.Navigate to your applications folder and locate the QGIS.app. Double click to launch.At this point, you can change your Mac security settings back to Allow apps downloaded from: Mac App Store and Identified Developers.

Tip

Note: QGIS requires the following versions of the MAC operating system: OS X Mavericks (10.9), Mountain Lion (10.8), or Lion (10.7).

Installing QGIS on Ubuntu Linux

There are two options when installing QGIS on Ubuntu: installing QGIS only, or installing QGIS as well as other Free and Open Source Software for Geographical Information Systems (FOSSGIS) packages. Either of these methods requires the use of the command line, sudo rights, and the apt-get package manager.

Installing QGIS only

Depending on whether you want to install a stable release or an experimental release, you will need to add the appropriate repository to the /etc/apt/sources.list file.

With sudo access, edit /etc/apt/sources.list and add the following line to install the current stable release or the current release's source code respectively:

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

Depending on the release version of Ubuntu you are using, you will need to specify the release name as trusty, saucy, or precise. For the latest list of QGIS releases for Ubuntu versions, visit download.qgis.org.

With the appropriate repository added, you can proceed with the QGIS installation by running the following commands:

sudo apt-get updatesudo apt-get install qgis python-qgis

To install the GRASS plugin (recommended), install the optional package by running this command:

sudo apt-get install qgis-plugin-grass

Installing QGIS and other FOSSGIS packages

The ubuntugis project installs QGIS and other FOSSGIS packages, such as GRASS, on Ubuntu. To install the ubuntugis package, remove the http://qgis.org/debian lines from the /etc/apt/sources.list file and run the following commands:

sudo apt-get install python-software-propertiessudo add-apt-repository ppa:ubuntugis/ubuntugis-unstablesudo apt-get updatesudo apt-get install qgis python-qgis qgis-plugin-grass

The following information box describes QGIS options for Android devices.

Note

There is an experimental version of QGIS available in the Google Play Store (https://play.google.com/store/apps/details?id=org.qgis.qgis). You can find more information about this at http://www.qgis.org/en/site/forusers/alldownloads.html#android.

The download page is available at http://qgis.org/downloads/android/.

A related data collection app has recently been announced and it is named QField. It is described as a field data capture and management app that is compatible with QGIS. It is available in the Google Play Store. You can find more information on this app at http://www.opengis.ch/android-gis/qfield/.

Installing QGIS on a Chromebook

It is possible to install Ubuntu Linux on a Chromebook via Crouton. This essentially creates a dual boot environment allowing you to switch between the Chrome OS and Ubuntu very quickly with some keyboard strokes. At that point, QGIS can also be installed normally on the Ubuntu OS. There are very thorough instructions for installing Ubuntu at the following link: http://www.voltron00x.com/?p=1091. If you would like to try this, it is best to purchase a Chromebook with the Intel Core i3 processor and 4 GB of RAM.

Tour of QGIS

QGIS is composed of two programs: QGIS Desktop and QGIS Browser. Desktop is used for managing, displaying, analyzing, and styling data. Browser is used to manage and preview data. This section will give you a brief tour of the graphical user interface components of both QGIS Desktop and QGIS Browser.

Familiarizing yourself with QGIS Desktop

The QGIS interface is divided into four interface types: Menu Bar, Toolbars, Panel, and Map Display. The following screenshot shows QGIS Desktop with all four interface types displayed:

The map display shows the styled data added to the QGIS project and, by default, takes up the majority of the space in QGIS Desktop. The menu bar, displayed across the top, provides access to most of QGIS Desktop's functionality. The toolbars provide quick access to QGIS Desktop functionality. The toolbars can be arranged to either float independently or dock at the top, bottom, left, or right sides of the application. The panels, such as Browser and Layers, provide a variety of functionality and can be arranged to either float independently or dock above, below, right, or left of the map display.

There are four toolbars that are particularly useful, and it is recommended that you enable them:

The File toolbar provides quick access to create, open, and save QGIS projects and create and manage print composersThe Manage Layers toolbar contains tools to add vectors, rasters, databases, web services, and text layers, and also create new layersThe Map Navigation toolbar contains tools that are useful for panning, zooming, and refreshing the map displayThe Attributes toolbar provides access to information, selection, field calculator, measuring, bookmarking, and annotation tools

QGIS Desktop offers a number of customization options. You can toggle the visibility of toolbars by navigating to View | Toolbars, or by right-clicking on the Menu Bar or the enabled Toolbars button, which will open a context menu allowing you to toggle toolbar and panel visibility. You can assign shortcut keys to operations by navigating to Settings | Configure shortcuts. You can also change application options such as interface language and rendering options by navigating to Settings | Options.

User interface themes

A new feature of QGIS Desktop is user interface themes. These are similar to skins for the application. These can be found by clicking Settings on the Menu bar and choosing Options. On the General tab, there is an option for UI Theme. If you are doing some late-night mapping, you might experience eye fatigue from the normal bright interface. Click the dropdown arrow and choose Night Mapping. The QGIS interface will switch to a dark skin.

You can also create your own themes. Start by reviewing the QSS style file that creates the Night Mapping theme from GitHub: https://github.com/qgis/QGIS/tree/master/resources/themes. To create a new theme, modify this file and save it to your .qgis2\themes folder.

Familiarizing yourself with QGIS Browser

The QGIS Browser interface (shown in the following screenshot) is composed of three parts: Toolbar, Data Tree view, and Information Panel:

The data tree view is an expandable tree listing of all geospatial data files on your computer and through connections. The information display, which takes most of the space on the application, contains four tabs that provide different views of the selected data in the data tree listing, and they are as follows:

Param: This tab displays details of data that is accessed through connections, such as a database or WMS.Metadata: This tab displays the metadata (if any) of the selected data.Preview: This tab renders the selected data. You can zoom into the data using your mouse wheel and pan using the arrow keys on your keyboard.Attributes: This tab displays the attribute table associated with the selected data. You can sort the columns by clicking on the column headings. This tab is only available for vector data.

The toolbar provides access to four functions. The Refresh function reloads the data tree view, while the Manage WMS function opens the WMS management screen allowing you to manage the WMS connections. The New Shapefile function opens the new vector layer dialog, allowing new shapefiles to be created. Finally, the Set layer CRS function allows you to define the coordinate reference system of the geospatial data file that is selected in the data tree view.

Loading data into QGIS Desktop

One strength of QGIS is its ability to load a large number of data types. In this section, we will cover loading various types of data into QGIS Desktop.

In general, data can be loaded in four ways. The first way, which will be covered in detail in this section, is to use the Add Layer menu under Layer and select the appropriate type of data that you wish to load. The second way is to open the Browser panel, navigate to the data you wish to load, and then drag the data onto the map display or onto the Layers panel. The third way to load data is to enable the Manage Layers toolbar and click on the button representing the data type that you wish to load. The fourth way is to locate the data in QGIS Browser, drag the data, and drop it onto the QGIS Desktop map display or the Layers panel.

Loading vector data

To load vector files, click on Add Vector Layer by navigating to Layer | Add Layer. This will open the Add Vector Layer dialog that will allow us to choose the source type and the source of the dataset that we wish to load.

The source type contains four options: File, Directory, Database, and Protocol. When you choose a source type, the source interface will change to display the appropriate options. Let's take a moment to discuss what types of data these four source types can load:

File: This can load flat files that are stored on disk. The commonly used flat file types are as follows:
ESRI shapefile (.shp)GeoJSON (.geojson)Geography Markup Language (.gml)AutoCAD DXF (.dxf)Comma separated values (.csv)GPS eXchange Format (.gpx)Keyhole Markup Language (.kml)SQLite/SpatiaLite (.sqlite/.db)
Directory: This can load data stored on disk that is encased in a directory. The commonly used directory types are as follows:
U.S. Census TIGER/LineArc/Info Binary Coverage
Database: This can load databases that are stored on disk or those available through service connections. The commonly used database types are as follows:
ODBCESRI Personal GeoDatabaseMSSQLMySQLPostgreSQL
Protocol: This can load protocols that are available at a specific URI. QGIS currently supports loading the GeoJSON and CouchDB protocols.

Loading raster data

To load raster data into QGIS, click on Add Raster Layer by navigating to Layer | Add Layer. This will open a file browser window and allow you to choose a GDAL-supported raster file. The commonly used raster types supported by GDAL are as follows:

ArcInfo ASCII Grid (.asc)Erdas Imagine (.img)GeoTIFF (.tif/.tiff)JPEG/JPEG-2000 (.jpg or .jpeg/.jp2 or .j2k)Portable Network Graphics (.png)Rasterlite (.sqlite)USGS Optional ASCII DEM (.dem)

To add an Oracle GeoRaster, click on Add Oracle GeoRaster Layer by navigating to Layer | Add Layer, then connect to an Oracle database to load the raster. More information about loading database layers is given in the following section.

Note

The Geospatial Data Abstraction Library (GDAL) is a free and open source library that translates and processes vector and raster geospatial data formats. QGIS, as well as many other programs, uses GDAL to handle many geospatial data processing tasks.

You may see references to OGR or GDAL/OGR as you work with QGIS and GDAL. OGR Simple Features Library references the vector processing parts of GDAL. OGR is not really a standalone project, as it is part of the GDAL code now; however, for historical reasons, OGR is still used. More information about GDAL and OGR can be found at http://gdal.org. GDAL is an OSGeo (http://osgeo.org) project.

Loading databases

QGIS supports PostGIS, SpatiaLite, Microsoft SQL Server, and Oracle databases. Regardless of the type of database you wish to load, the loading sequence is very similar. Therefore, instead of covering specific examples, the general sequence will be covered.

First, click on Add Layer under Layer and then choose the database type you wish to load. This will open a window with options for adding the data stored in a database. As an example, the following screenshot shows the window that opens when you navigate to Layer | Add Layer | Add SpatiaLite Layer:

Tip

Note that the window will look the same for any database you choose, except for the window name.

To load data from a database, we must first create a connection to the database. To create a new connection, click on the New button to open a connection information window. Depending on the database type you are connecting to, different connection options will be shown. Once you have created a database connection, select it from the drop-down list and click on Connect; you will see a list of all layers contained within the database display. If there are a large number of tables, you can select Search options and perform a search on the database. To load a layer, select it in the list and click on Add. If you only wish to load a portion of the layer, select the layer and then click on Set Filter to open the query builder. If you set a query and then add the layer, only the filtered features will be added.

Loading web services

QGIS supports the loading of OGC-compliant web services such as WMS/WMTS, WCS, and WFS. Loading a web service is similar to loading a database service, in that you must first set up the connection to the service, then connect to the service to choose which layers to add to the map canvas.

As an example, to add a WMS service, click Layer | Add Layer | Add WMS/WMTS Layer. On the window that appears, click New to open the Create a new WMS connection window (shown in the following figure) where you can define the parameters of the new service. Enter a Name for the service, the URL of the service, set any of the remaining options that may apply, and then click OK to add the service as an available connection.

With the new service added, make sure it is selected, then click Connect to connect to the service, and list the available layers. To add a layer to the map canvas, select it, choose the Image encoding, Coordinate Reference System, and Layer name, and then click Add.

Tip

Some services support multiple CRS. After connecting to a service, select a layer and then click Change to choose the coordinate system to use.

Working with CRS

When working with spatial data, it is important that a CRS is assigned to the data and the QGIS project. To view the CRS for the QGIS project, click on Project Properties under Project and choose the CRS tab.

It is recommended that all data added to a QGIS project be projected into the same CRS as the QGIS project. However, if this is not possible or convenient, QGIS can project layers on the fly to the project's CRS.

Note

If you want to quickly search for a CRS, you can enter the EPSG code to quickly filter through the CRS list. An EPSG code refers to a specific CRS stored in the EPSG Geodetic Parameter Dataset online registry which contains numerous global, regional, and local CRS. An example of a commonly used EPSG code is 4326, which refers to WGS 84. The EPSG online registry is available at http://www.epsg-registry.org/.

To enable on-the-fly projection, perform the following steps:

Click on Project Properties under Project.Choose the CRS tab and Enable 'on the fly' CRS transformation.Set the CRS that you wish to apply to the project and make all layers that are not set to the project's CRS transform on the fly.

To view the CRS for a layer, perform the following steps:

Open the layer's properties by either navigating to Layer | Properties or by right-clicking on the layer in the Layers panel.Choose Properties from the context menu and then choose the General tab.If the layer's CRS is not set or is incorrect, click on Specify to open the CRS selector window and select the correct CRS.

To project a layer to a different CRS, perform the following steps:

Right-click on the layer in the Layers panel and then choose Save As from the context menu.In the Save vector layer as dialog, set the file format and filename, then set CRS to Selected CRS, click on Change to set the target CRS, and save the file.

To create a new CRS or modify an existing CRS, perform the following steps:

Click on Custom CRS under Settings to open the Custom Coordinate Reference System Definition window.Click on the Add new CRS button to add a new entry to the CRS list.With the new CRS selected, we can set the name and parameters of the CRS. The CRS properties are set using the PROJ.4 format. To modify an existing CRS, click on Copy existing CRS and select the CRS from which you wish to copy parameters; otherwise, enter the parameters manually. Some background on PROJ.4 is provided below.

Tip

PROJ.4 is another OSGeo (http://osgeo.org) project used by QGIS, and it is similar to OGR and GDAL. This project is for managing coordinate systems and projections. For a detailed user manual for the PROJ.4 format used to specify the CRS parameters in QGIS, download it from http://download.osgeo.org/proj/OF90-284.pdf.

Working with tables

There are two types of table you can work with in QGIS: attribute tables and standalone tables. Whether they are from a database or associated with a shapefile or a flat file, they are all treated the same. Standalone tables can be added by clicking on the Add Vector Layer menu by navigating to Layer | Add Layer. QGIS supports the table formats supported by OGR, along with database tables. Tables are treated like any other GIS layer; they simply have no geometry. Both types of table can be opened within Desktop by selecting the layer/table in the Layers panel, and then by either clicking on Open Attribute Table under Layer, or by right-clicking on the data layer and choosing Open Attribute Table from the context menu. They can also be previewed in QGIS Browser by choosing the Attributes tab.

The table opens in a new window that displays the number of table rows and selected records in the title bar. Below the title bar are a series of buttons that allow you to toggle between editing, managing selections, and adding and deleting columns. Most of the window is filled with the table body. The table can be sorted by clicking on the column names. An arrow will appear in the column header, indicating either an ascending or a descending sort. Rows can be selected by clicking on the row number on the left-hand side. In the lower-left corner is a Tables menu that allows you to manage what portions of the table should be displayed. You can choose Show All Features (default setting), Show Selected Features, Show Features Visible on Map (only available when you view an attribute table), Show Edited and New Features, create column filters, and advanced filters (expression).

The lower-right corner has a toggle between the default table view and a forms view of the table. An attribute table is shown in the following screenshot, with parts of the table window identified:

Attribute tables are associated with the features of a GIS layer. Typically, one record in the attribute table corresponds to one feature in the GIS layer. Standalone tables are not associated with GIS data layers. However, they may have data of a spatial nature from which a spatial data layer can be generated (for more information, see Chapter 6, Advanced Data Creation and Editing). They may also contain data that you wish to join to an existing attribute table with a table join, which we will cover in the next section.

Creating table joins

Let's say that you need to make a map of the total population by county. However, the counties' GIS layers do not have population as an attribute. Instead, this data is contained in an Excel spreadsheet. It is possible to join additional tabular data to an existing attribute table.

There are two requirements, which are as follows:

The two tables need to share fields with attributes to match for joiningThere needs to be a cardinality of one-to-one or many-to-one between the attribute table and the standalone table

To create a join, load both the GIS layer and the standalone table into QGIS Desktop. QGIS will accept a variety of standalone table file formats including Excel spreadsheets (.xls and .xlsx), dBase (.dbf) files, and comma separated value (.csv) files. You can load this tabular data using the Add Vector Layer menu by navigating to Layer | Add Layer and setting the file type filter to All files (*) (*.*) as shown in the following screenshot:

Once the data is loaded, a join can be completed by following these steps:

Select the GIS layer in the Layers panel that will receive the new data from the join.Navigate to Layer | Properties and choose the Joins tab.Click on the add join button (the one with a green plus sign).Choose the Join layer, Join field, and Target field values. The Join layer and Join field values represent the standalone table. The Target field value is the column in the attribute table on which the join will be based.

Note

Although in this example the join field and the target field have the same name, this is not a requirement. The two fields merely need to hold the same unique ID.

At this point, you can choose Cache join layer in virtual memory, Create attribute index on join field, or Choose which fields are joined. The last option lets you to choose which fields from the join layer to append to the attribute table. A new feature also allows you to set a Custom field name prefix. At this point, the Add vector join window will look like the following screenshot.Once created, the join will be listed on the Joins tab. The extra attribute columns from the Join layer will be appended to the attribute table, where the value in the Join field matched the value in the Target field.The additional data from the join can be used to query the data and style the data.Joins can be modified by selecting the join and clicking the pencil edit button. They can be removed by clicking on the remove join button (the one with a red minus sign):

Tip

Joins only exist in virtual memory within the QGIS Desktop document. To preserve the join outside the map document, click on Save as... under Layer and save a new copy of the layer. The new layer will include the attributes appended via the join.

Editing data

Vector data layers can be edited within QGIS Desktop. Editing allows you to add, delete, and modify features in vector datasets. The first step is to put the dataset into edit mode. Select the layer in the Layers panel and click on Toggle Editing under Layer. Alternatively, you can right-click on a layer in the Layers panel and choose Toggle Editing from the context menu. Multiple layers can be edited at a time. The layer currently being edited is the one selected in the Layers panel. Once you are in the edit mode, the digitizing toolbar (shown in the following screenshot) can be used to add, delete, and modify features:

From left to right, the tools in the digitizing toolbar are as follows:

The Current Edits tool allows you to manage your editing session. Here, you can save and roll back edits for one or more selected layers.The Toggle Editing tool provides an additional means to begin or end an editing session for a selected layer.The Save Layer Edits tool allows you to save edits for the selected layer(s) during an editing session.The Add Features