Home Programming Learn QGIS - Fourth Edition

Learn QGIS - Fourth Edition

By Andrew Cutts , Anita Graser
books-svg-icon Book
eBook $35.99 $24.99
Print $43.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $35.99 $24.99
Print $43.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
About this book
QGIS 3.4 is the first LTR (long term release) of QGIS version 3. This is a giant leap forward for the project with tons of new features and impactful changes. Learn QGIS is fully updated for QGIS 3.4, covering its processing engine update, Python 3 de-facto coding environment, and the GeoPackage format. This book will help you get started on your QGIS journey, guiding you to develop your own processing pathway. You will explore the user interface, loading your data, editing, and then creating data. QGIS often surprises new users with its mapping capabilities; you will discover how easily you can style and create your first map. But that’s not all! In the final part of the book, you’ll learn about spatial analysis and the powerful tools in QGIS, and conclude by looking at Python processing options. By the end of the book, you will have become proficient in geospatial analysis using QGIS and Python.
Publication date:
November 2018
Publisher
Packt
Pages
272
ISBN
9781788997423

 

Where Do I Start?

Welcome to QGIS. There has never been a better time to start using QGIS, you have made a great choice! You may have already started using QGIS 3.4, you may have experience with older versions, or you may be familiar with other GIS software. No matter where you are on your learning journey, the first time you install any software can be a little daunting.

This chapter is all about getting a feel for the software, building your confidence, and developing the urge to explore. By the end of this chapter, you will grasped some of the basic ideas and concepts.You will be in the perfect position to begin working with data, designing and styling it, and working toward creating a map.

In this chapter, we will cover the following topics:

  • Installing QGIS
  • What has changed since QGIS 2.x?
  • Toolbars and GUI
  • Getting help
  • Setting up
  • Community of users
 

Installing QGIS 3.4

QGIS runs on all operating systems; it is even possible to install it on a Raspberry Pi. The QGIS project provides ready-to-use packages as well as instructions to build from source code at http://download.qgis.org. Here, we will cover how to install QGIS on two systems: Windows and Ubuntu.

Full installation instructions for every supported operating system are available at http://www.qgis.org/en/site/forusers/alldownloads.html.

Like many other open source projects, QGIS offers you a choice between different releases. For the tutorials in this book, we will use the QGIS 3.4 long term release (LTR) version. We recommend installing this version in order to follow this book with ease. As you build familiarity and confidence, you may wish to work with different versions. The core QGIS functionality generally remains the same. Newer versions will include the latest release (LR), which is normally updated every four months, or the developer version (DEV) for which you can get nightly builds, if needed. While exciting, the DEV version should not be relied on for anything other than testing or inspecting new features.

You can find more information about the releases as well as the schedule for future releases at http://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule.
For an overview of the changes between releases, check out the visual change logs at http://www.qgis.org/en/site/forusers/visualchangelogs.html.

Installing QGIS on Windows

On Windows, we have two different options for installing QGIS. These are the OSGeo4W and the standalone installer.

The OSGeo4W installer is a small, flexible installation tool that makes it possible to download and install QGIS and many more OSGeo tools with all their dependencies. The main advantage of this installer over the standalone installer is that it makes updating QGIS and its dependencies very easy. I recommend that you use OSGeo4W where practical. You can download the 32-bit and/or the 64-bit OSGeo4W installers from http://osgeo4w.osgeo.org . You can download directly from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe for the 32-bit version. If you have a 64-bit version of Windows, you can also download from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe. Download the version that matches your operating system and keep it. In the future, whenever you want to change or update your system, just run it again.

If you prefer, you can use the standalone installer. This is one file to download (approximately 400 MB in size). It contains a QGIS release, the Geographic Resources Analysis Support System (GRASS) GIS, and the System for Automated Geoscientific Analyses (SAGA) GIS in one package. For a beginning, this is the easiest installation option.

Installing QGIS using the OSGeo4W installer

In this section, we will focus on installing QGIS using the OSGeo4W installer. This is a convenient way to install QGIS and a host of other open source GIS tools.

QGIS 3.4 will, in February 2019, become the first LTR of QGIS 3 replacing 2.18.

Latest QGIS release

Start by double-clicking on OSGeo4W executable. This will lead you to the following screenshot:

OSGeo4W setup screen

Select the Express Desktop Install radio button. This may not install QGIS 3.4. If you wish to specify a version, please see the next section on Advanced Installers. The Advanced Install radio button is useful if you want to customize your installation, or choose your installation version or perhaps by install the development version of QGIS:

Setting the express package selection

Accept the defaults and click on the Next button. This will set off the download process. Progress will be displayed as each component is downloaded. Having these installed will provide you with more tools to perform Geospatial analysis. After a short period of time, you should see OSGeo4W in your programs menu along with all the other installed software, similar to the following screenshot:

How QGIS appears in Windows

If QGIS is appearing in your programs menu, then it is now installed on your machine.

It is possible to have multiple versions of QGIS installed on Windows. This may mean that you could have QGIS 2 and QGIS 3 running on the same machine. Please remember QGIS 3 projects will not open in QGIS 2. You may need to have two versions installed if you are reliant on a plugin that is no longer supported or has as yet to be ported to QGIS 3.

Advanced installer (to specify version)

Select the radio button next to Advanced Install, as shown in the following screenshot:

Advanced installer

Step through the installation wizard. When you get to the Select Packages, choose the version you require. In the following screenshot I have selected the 3.4.0-1 release:

Installing QGIS 3.4 via advanced install

You can select other packages if required. Once you have chosen the software, click on the Next button. Step through the wizard by accepting the defaults and the installation will begin.

Installing on Ubuntu

On Ubuntu, the QGIS project provides packages for the LTR, LR, and DEV versions. For this book, we recommend installing the LTR version of 3.4 if available (release date: February 2019).

To avoid conflicts that may occur due to incompatible packages, make sure that you only add one of the following package source options. The specific lines that you have to add to the source list depend on your Ubuntu version. The following version is latest release for Debian stretch:

deb     https://qgis.org/debian stretch main
deb-src https://qgis.org/debian stretch main

After choosing the repository, we will add the qgis.org repository's public key to our apt keyring. This will avoid the warnings that you might otherwise get when installing from a non-default repository. Run the following command in the terminal:

wget -O - https://qgis.org/downloads/qgis-2017.gpg.key | gpg --import
gpg --fingerprint CAEB3DC3BDF7FB45
gpg --export --armor CAEB3DC3BDF7FB45 | sudo apt-key add -
You might need to make adjustments based on your system. For an updated list of supported Ubuntu versions, check out http://www.qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu. By the time this book goes to print, the key information might have changed. Refer to http://www.qgis.org/en/site/forusers/alldownloads.html#debian-ubuntu for the latest updates.

Finally, to install QGIS, run the following commands. The first will fetch any updates to packages on your system, and the second will install QGIS, the python library, and the grass plugins:

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

Running QGIS for the first time

In recent years, QGIS has become the most popular open source desktop GIS software. Some people are using it just to view and query data, while others are using it for much deeper analyses. Maybe you are an ecologist or a town planner needing to use GIS as part of your job. Maybe you have a background in proprietary GIS software and want to migrate some of your common workflows to open source. Or maybe you are a student that needs to use GIS for a project. Whatever your driving reason is for opening this book, welcome to an amazing community that is passionate about open source and GIS.

The following screenshot shows how QGIS 3.4 will look when it is first opened. In this case, there are no recent projects here and the interface is uncustomized:

How QGIS appears once opened for the first time

On the first run, not all toolbars are enabled. You can enable all the default toolbars (meaning the ones not associated with any additional plugins) via Toolbars in the View menu. Set up the QGIS environment according to your personal preferences via the Toolbars option shown in the following screenshot:

Setting the toolbars
Leave the default settings enabled for this book. We will guide you through the toolbars and panels in detail in later sections.

Plugins

Plugins are a unique feature of QGIS. In Chapter 6, Extending QGIS with Python, we will cover how to build your own. Plugins are available to be installed as you need them to enable further analysis. If what you want to do is not available within your current QGIS setup, search in the plugins as someone may have developed a tool to help you reach your solution. To access the Plugins, navigate to Plugins in the menu and then select Manage and Install Plugins:

Opening the Plugins menu

By clicking on the preceding option, the following window will be displayed:

List of plugins currently installed

The Plugins window will display the number of plugins installed in parentheses. In the preceding example, 272 are shown. You can search for plugins in the search box, install or upgrade individual plugins, or Upgrade All. Plugins are activated by ticking the check boxes beside their names. In QGIS 3.4, an icon will appear in the bottom-right corner of the information bar if there are any updates available for the your installed plugins.

For a list of all the available Plugins, including the latest and most popular, navigate to https://plugins.qgis.org/. This is an ever-growing list!
 

What is new in QGIS 3

QGIS 3 has been ported to support Python 3, so if you are familiar with previous versions of QGIS, some of the older plugins may not be compatible. These will either have been updated or will be in the process of being updated, some are also obsolete (because their functionality is now part of QGIS core) or abandoned by the original developer. In terms of the GUI, not a great deal has changed. If you have previous experience, it should be mostly familiar to you.

Some of the major changes that have taken place for QGIS 3 include processing in the background. This enables you to continue working while processing continues, rather than waiting for QGIS to complete tasks. The processing toolbox has been updated, meaning that many of the tools now execute faster than in QGIS 2.x. There has also been a significant update in the way maps are authored and data is styled. We will be covering this in detail in Chapter 3, Visualizing Data. There is a really useful search feature in the bottom-left corner of the QGIS information bar, allowing you to search for tools, layers, and features. Finally, QGIS now supports GeoPackage and is using it as its default GIS format.

We will cover all of these new features in this book using examples to bring QGIS to life.

For a comprehensive list of all the major updates, please see the change log at http://changelog.qgis.org/en/qgis/version/3.0.0/. To see the latest changes between version, check out https://qgis.org/en/site/forusers/visualchangelogs.html.
 

Introducing the QGIS user interface

Now that we have set up QGIS, let's get accustomed to the interface. The following screenshot shows a breakdown of QGIS. The main part of the screen is dominated by the map display, which can be adjusted as needed.

The Processing Toolbox can be added by clicking View | Panels | Processing Toolbox:


Overview of QGIS

The biggest area is reserved for the map. To the left of the map, there are the Layers and Browser panels. Under the map, we can see the information bar, which includes (from left to right):

  • Search box
  • The current map Coordinate
  • Map scale
  • Magnifier
  • Rotation
  • A checkbox for render
  • The project coordinate reference system (CRS)
  • Messages (logs)
  • Updates available for plugins

In this screenshot, EPSG:4326 is shown. On the right side is the Processing Toolbox, which also has a search function. Finally, at the top of QGIS, you can see the project title (as yet unnamed), menus, and toolbars.

Menu bar

Options in the menu bar are frequently repeated in buttons contained in the toolbars. As you explore these menus, you will notice icons next to some of the options. These shortcut buttons on toolbars often become the easiest way to interact with QGIS. The following is a screenshot of the menu bar:

Menu bar

The Vector and Raster menus are worth exploring, and we will do this in Chapter 5, Spatial Analysis. You will often find that new plugins insert additional options within these menus or even create new menus. As we move through this book, we will often refer to the menu bar by just the name of the menu. For example, Database | DB Manager means click on Database menu and then the DB Manager option within that menu.

Toolbars

There are multiple toolbars to explore; let's take a look at some of the main ones. Toolbars are fully adjustable and dockable. The faint upright dots (in Windows) indicate the start of a toolbar and a faint vertical line indicates the end of a toolbar.

  • Project: This toolbar contains the tools needed to create, open, save, and access the print layout (two buttons) and the style manger:
Project toolbar
  • Map Navigation: This toolbar contains the pan and zoom tools, as well as bookmarks (customized zoom) and map refresh:
Map Navigation
  • Attributes: These tools are used to identify, select, open attribute tables, and measure:
Attribute toolbar
  • Label: These tools are used to add, configure, and modify labels
  • Plugins: This currently only contains the Python Console tool, but will be filled in by additional Python plugins
  • Database: Currently, this toolbar only contains DB Manager
  • Raster: This toolbar includes histogram stretch, and brightness and contrast control
  • Vector: This currently only contains the Coordinate Capture tool, but it will be filled in by additional Python plugins
  • Web: This is currently empty, but it will also be filled in by additional Python plugins
  • Help: This toolbar points to the option for downloading the user manual

All these toolbars are shown in the following screenshot:

Many of the common tools grouped together

On the left screen border, we place the Manage Layers toolbar. This toolbar contains the tools for adding layers from the vector or raster files, databases, web services, and text files. It also contains the tools for creating new layers:

Manage layers toolbar
  • Digitizing: The tools in this toolbar enable basic feature-creation and editing.
  • Shape Digitizing: Useful for quickly building different shapes when editing.
  • Advanced Digitizing: This toolbar contains the Undo/Redo option, advanced editing tools, the geometry-simplification tool, and so on. When activated, the right part of the screenshot is accessible:
All the editing tools
  • The data source manager toolbar contains buttons to quickly create new geopackage files and shapefiles, as well as calling the data source manager and creating temporary scratch layers:
Data source manager toolbar

Toolbars can be accessed by right-clicking on a menu or toolbar, which will open a context menu with all the available toolbars and panels. All the tools on the toolbars can also be accessed via the menu. If you deactivate the Manage Layers Toolbar, for example, you will still be able to add layers using the Layer menu.

As you might have guessed by now, QGIS is highly customizable. You can increase your productivity by assigning shortcuts to the tools you use regularly. You can do this by going to Settings | Configure Shortcuts. Similarly, if you realize that you never use a certain toolbar button or menu entry, you can hide it by going to Settings | Interface Customization:

Customization of the user interface

Information bar

The information bar is useful for finding out about the projection and navigation of the map. The information bar also contains icons about any log messages (potential errors) and any plugins with updates pending. It is shown in the following screenshot, and is located at the bottom of the QGIS window:

Information bar

The search function is one of the new features in QGIS 3 and this helps to find processing tools or layers. You can use the shortcut keys shown in the following screenshot:

Using the shortcut keys

Alternatively, you can search directly for what you are looking for. For example, you can simply search for a buffer in the information bar search and the results will be similar to the following screenshot:

Searching for buffer tools

Layers and browser panels

Browser and Layers panels describe where data is stored and how that data is displayed. Now is a great time to download some sample data. Head over to https://qgis.org/downloads/data/ and download training_manual_execise_data.zip. Extract it in a folder of your choice and then navigate to that folder in the Browser window.

I have located the basic_map.tif and forest_stands_2012.shp files and dragged them both into the Layers window. We will look at styling layers in Chapter 3, Visualizing Data, and then cover how to create a map in Chapter 4, Creating Great Maps.Lets take a look at Browser and Layers Panels in the following screenshot:

Browser and Layers Panels

Map

Now that we have added some data to the Layers window, the data will appear in the map. The following screenshot shows two layers that I have added to the map: one vector (forest_stands_2012) and one raster (basic_map):

QGIS with some data added

The data has appeared! Notice that the projection in the information bar has changed; QGIS 3 supports on-the-fly projections. Finally, we have to save the project.The new default format is .qgz. Select Project | Save, and the window shown in the following screenshot will appear:

Saving a QGIS project

If you now click Project | New, you should see your saved project in the Browser window:

How the project appears in the Browser window

To load the project again, double-click on the project name.

You can sometimes open QGIS 2.x projects in QGIS 3, but you cannot open QGIS 3 projects in QGIS 2.x, so be careful.

 

Finding help and reporting issues

The QGIS community offers a variety of different community-based support options. These include the following:

Before contacting community support, it's recommended to take a look at the documentation at http://docs.qgis.org.

If you prefer commercial support, you can find a list of companies that provide support and custom development at http://www.qgis.org/en/site/forusers/commercial_support.html#qgis-commercial-support.

If you find a bug, please report it because the QGIS developers can only fix the bugs that they are aware of. For details on how to report bugs, visit http://www.qgis.org/en/site/getinvolved/development/bugreporting.html.

 

Summary

In this chapter, we installed QGIS 3.4 and took a first look at the interface. We highlighted some of the exciting new features in the QGIS 3.4 release and looked at how they will impact us. We also explored the panels, toolbars, and menus that make up the QGIS user interface. At the end of the chapter, we interacted with the browser and the layers panel by dragging our data in and looking at how to save a project. Finally, we covered where to find help and report issues. In the next chapter, we will use QGIS to work with data.

About the Authors
  • Andrew Cutts

    Andrew Cutts holds a geography degree and a masters degree in GIS and has almost 20 years of experience in working with geospatial technology. He currently works as a freelance geospatial consultant. He has worked in local government, large multinational companies, and small and medium-sized enterprises. He has run a geospatial blog for almost 3 years and is a co-host of the #scenefromabove podcast. Andrew has spoken at events worldwide on GIS and Earth observation. He is a keen user of Python, especially for rapid prototyping for geospatial challenges. Currently, he is working with clients to maximize their investment with geospatial technology through direct consulting, training, and technical writing.

    Browse publications by this author
  • Anita Graser

    Anita Graser is a spatial data scientist, open source GIS advocate, and author with a background in geographic information science. She is currently working with the Center for Mobility Systems at the Austrian Institute of Technology in Vienna and teaching QGIS classes at UNIGIS Salzburg. She serves on the QGIS project steering committee. and has published several books about QGIS. Furthermore, she develops tools, such as the Time Manager plugin for QGIS. You can follow her on Twitter @underdarkGIS.

    Browse publications by this author
Latest Reviews (12 reviews total)
cartea este foarte buna si imi place.
Overall a really good introduction to QGIS 3.4. I am a relative beginner and bought the book after a recent practical QGIS workshop. I have found the book easy to navigate and easy to dip in and out of for reminders on procedures. Good material on GeoPackage layers which wasn't covered on my workshop. The index could be more comprehensive. I couldn't find any thing to do with using the Georeferencing plugin which is installed with QGIS 3.4 so had to look that up on line. Overall very happy with my purchase!
The supplementary materials help to speed up understanding and insight.
Learn QGIS - Fourth Edition
Unlock this book and the full library FREE for 7 days
Start now