Mastering Geospatial Development with QGIS 3.x - Third Edition

1 (1 reviews total)
By Shammunul Islam , Simon Miles , Kurt Menke, GISP and 3 more
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Free Chapter
    A Refreshing Look at QGIS
About this book
QGIS is an open source solution to GIS and widely used by GIS professionals all over the world. It is the leading alternative to 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 and getting you acquainted with the latest QGIS 3.6 updates, this book will take you all the way through to teaching you how to create a spatial database and a GeoPackage. Next, you will learn how to style raster and vector data by choosing and managing different colors. The book will then focus on processing raster and vector data. You will be then taught advanced applications, such as creating and editing vector data. Along with that, you will also learn about the newly updated Processing Toolbox, which will help you develop the advanced data visualizations. The book will then explain to you the graphic modeler, how to create QGIS plugins with PyQGIS, and how to integrate Python analysis scripts with QGIS. By the end of the book, you will understand how to work with all aspects of QGIS and will be ready to use it for any type of GIS work.
Publication date:
March 2019


Chapter 1. A Refreshing Look at QGIS

In this chapter, we will review the basic functionality of QGIS and explore some of the new features of versions starting from 3.4. If you need a refresher on QGIS or a quickstart guide to QGIS, you should read this chapter. The topics we will cover in this chapter are as follows:

  • Downloading QGIS and its installation
  • The QGIS graphical user interface
  • Loading data
  • Working with coordinate reference systems (CRS)
  • Working with tables
  • Editing data
  • Styling data
  • Composing a map
  • Finding and installing plugins

QGIS is a volunteer-led development project licensed under the GNU General Public License, and was started by Gary Sherman in 2002. The project was incubated with the Open Source Geospatial Foundation (OSGeo) in 2007, with QGIS 1.0 being 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. QGIS user groups exist as well, aiming to bring people together to share experiences of QGIS. It is easy to get involved, and the authors encourage you to consider contributing. Learn about how to get involved at


Release schedules

Currently, a new version of QGIS is released around 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, QGIS 3.4.5 is the current LTR, with version 3.6 available for download.


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


QGIS downloading and installation

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

Installing QGIS on Windows

On the QGIS website, download the correct version of QGIS for your Windows machine. Downloadable executable files come in 32-bit and 64-bit flavors. We recommend downloading the latest release as advertised on the QGIS website download page. 

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. This is also the ideal installation method for organizations or businesses wishing to deploy QGIS to multiple users.
  • 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.

If you are unsure on how to install QGIS, the QGIS website contains details on how to do this.

Installing QGIS on macOS

The QGIS website provides download mac installer packages for macOS, that contain readme files for the installation of QGIS. Documentation and support for QGIS on macOS has greatly improved, and while it is beyond the scope of this chapter to detail the install process and document any possible issues that might incur during installation, the GIS Stack Exchange ( is a great refresh resource.

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 source code, respectively:

deb trusty main 
deb-src 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

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

sudo apt-get update
sudo 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 lines from the /etc/apt/sources.list file and run the following commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install qgis python-qgis qgis-plugin-grass

QGIS on Android

At the time of writing, there is really only one Android QGIS application available on Google Play, called QField, developed by from Switzerland. Users of QGIS can save their projects to their Android device and then reopen them in QField. The application comes with Geolocation capabilities, data editing, and photos captured, to name just a few of its features.


Further information on QField can be found at

While QField may currently (at the time of writing) be one of the main Android QGIS applications available, the underlying architecture of QGIS, namely QT5 and Python3, mean that development and deployment of user-created Android applications is not far away, thanks to crowdfunding opportunities organized by such companies as Lutra Consultancy and North Road.

Installing QGIS on a Chromebook

It is possible to install the Ubuntu Linux operating system 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. Once Crouton is set up, QGIS can be installed via the preceding Ubuntu QGIS install processes. 


While Chromebooks are relatively cheap, they are weak, if not lacking, in hardware such as graphic cards. Therefore, while it is possible to install QGIS on a Chromebook, we would suggest that doing so is for hobbyists looking to explore/test the capabilities of this union and that it would not be suitable for production environments.

QGIS in a browser

Using the RollApp website (, you can access QGIS, plus a range of other open source software in your web browser. This means that for Chromebook and iPad (for example), users can access QGIS without physically installing any software or making system configuration changes. RollApp is designed around using cloud base storage, such as Google Drive, Dropbox, and Box. This makes sharing data and projects very easy.


What's new?

With the release of version 3 of QGIS comes a host of new features and tools—far too many to document here, but if you are interested, take a look at For the new addition to QGIS 3.6, have a look at this The biggest shift in QGIS 3.x is the migration from Python 2 to 3, which has extended the functionality to run scripts, processes, and tasks. Further to this, the underlying application used to build the QGIS interface, called Qt as of version 3.x, runs off Qt5.

To highlight perhaps just a few of these new features, note the following:

  • Data Source Manager: The Data Source Manager (accessed via 
     or Ctrl + L) is perhaps the most notable visual change of 3.4, as it is presented as the default tool to accessing data to load onto theMap Canvas:
  • Opening layers over HTTP(s), FTP, and cloud storage: Sharing and accessing data through QGIS has gotten a whole lot easier with 3.x series. No longer does data need to be stored on a local or networked drive; instead, data can be accessed through HTTP(s), FTP, or via cloud storage providers such as Google Drive. There are now really no limits as to how QGIS can fetch, receive, and display GIS data.
  • Filters: In previous versions of QGIS, it has been difficult to know which layers have had filters applied to them. In version 3.4, this has been remedied with a filter icon being placed on all layers that have filters applied. A user can click on the filter icon to gain quick access to the query builder.
  • Import geotagged photos: Photos that have been geotagged (which is commonly set as a default function on most modern smartphones) can now be uploaded onto the Map Canvas and represented as a point value. The metadata associated with the photo can also be accessed.
  • Save project to Postgres: This is a truly remarkable step forward for QGIS. The ability to save a QGIS project to a database table adds a new level of security, but also accessibility, to QGIS. It is now possible to simply send someone postgres connection details and, once added into QGIS, this will allow the user to access permission-based projects and layers (tables) stored on the database. This means that no data, no projects, and indeed, no physical files need to be handled by a user to access QGIS data.
  • Locator Search Bar: Located in the bottom left, below the panels, is the Locator Search bar that is a quick finder for processes, tools, and can even be configured to search layers.
  • 3D and mesh: There has been significant investment in 3D in version 3. 3D views of data can now be seen in its own Map View, which runs in parallel to the main Map Canvas. Mesh data can now be loaded into QGIS and viewed in 3D.
  • Print Layouts: Other than a change of name from Print Compose to Print Layouts, QGIS 3.4 brings some new elements to the Print window, such as the ability to add 3D views. There have been changes to the Item Properties to increase overall functionality.
  • Identity tool for mesh layers: In QGIS 3.6, we can use Identify tool with mesh layer. We can see the value of both scalar and vector component 


To have a look at the features of QGIS 3.6, please visit this link: For a look at the new editions in QGIS 3.4, please refer to this link: If you visit any of these pages, you will find link for new features for all the versions of QGIS.


A 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 for managing and previewing 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 Canvas. The following screenshot shows QGIS Desktop with all four interface types displayed:

The Map Canvas shows the styled data added to the QGIS project. The Menu Bar, displayed across the top, provides access to most of the QGIS functions. The Toolbars provide quick access to QGIS core functionality. The Toolbars can be arranged to either float independently or dock at the top, bottom, left, or right sides of the application—equally, toolbar ideas can be removed from the screen via Settings | Interface Customization.


If you are going to use the Interface Customization tool to remove icons, make a backup file first of the current UI (User Interface) of QGIS. When the Enable Customization button is checked, click on the Save button and save the .ini file to a safe place. Then, make your changes but remove icons and so on. If you ever what QGIS looking as it did, prior to the removal of icons that you made, use the Loadfrom file option to reinstall the original backup .ini file that you created. Note that if you change the UI via the Interface Customization tool, then you'll need to close QGSIS before you see the changes take effect.

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 or side by side as tabs.

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 and then enabling the Toolbars button, which will open a context menu allowing you to toggle the 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.

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 a number of ways. The main way, which will be covered in detail in this section, is to use the Data Source Manager.

Alternatively, using the Browser panel, navigate to the data you wish to load, and then either drag the data onto the Map Canvas or right-mouse click on it and choose Add Selected Layer(s) to canvas.

Under Settings | Add Layer from the main Menu.

Also, you can drag and drop data/files from your native operating systems file manager. Even ZIP files that contain .shp files can be added to the Map Canvas in this way.

Loading vector data

To load vector files using the Data Source Manager, click on the Open Data Source Managericon

, or press Ctrl + L. From the list of layer types on the left, choose Vector. You now have the option to load a Vector file for a number of Source type options:

The source type contains four options: File, Directory, Database, and Protocol: HTTP(S), cloud, etc. 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:


There is a big push to move users away from using ESRI shapefiles, replacing it instead with GeoPackages (more will be discussed about these later). QGIS, in the first instance, will prompt you to save to this format over .shp.

  • File: This can load flat files that are stored on disk. The commonly used flat file types are as follows:
    • GeoPackage (.gpkg)
    • 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/Line
    • Arc/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:
    • ODBC
    • ESRI Personal GeoDatabase
    • MSSQL
    • MySQL
    • PostgreSQL
  • Protocol: This can load protocols that are available at a specific URL. In QGIS 3.4, these protocols have been extended to include calls to HTTP/HTTPS/FTP, AWS S3, and Google Cloud Storage, adding to the previous GeoJSON and CouchDB options:

Loading raster data

To load raster files using the Data Source Manager, click on the Open Data Source Manager icon 

, or press Ctrl + L. From the list of layer types on the left, choose Raster.

You now have the option to load a raster file for File or Protocol: HTTP(S), cloud, etc. (much like Vector):

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)


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 GDAL is an OSGeo ( 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.

To create a new database connection using the Data Source Manager, perform the following:

  1. Click on the OpenData Source Manager icon
    or press Ctrl + L
  2. On the left, choose the database you want to connect to, and, in the connection window, click on the New button
  3. Add all the connection details required

To add a layer once a connection has been established, perform the following:

  1. Click on the Open Data Source Manager icon
  2. Click on Connect

When connected successfully, you will be presented with a list of layers that can be added to the Map Canvas. An alternative and perhaps better method for loading data on the Map Canvas is to use the Browser panel once you have created the new database connection. Using the Browser panel gives the user a cleaner overview of the layers and tables that can be added to the Map Canvas


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

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, and then connect to the service to choose which layers to add to the Map Canvas.

As an example, to add a WMS service, click on the Open Data Source Manager icon 

or press Ctrl + L, and, on the left-hand side of the window, click on WMS/WMTS.

Click on the New button and give the new connection details a name (this is a free text friend, so the name can be anything you wish) and then add in the URL of the WMS/WMTS. Once completed, click on OK.

As with viewing data from databases in the previous section, to view the data available via the connection that you have established via the Data Source Manager, it is best to access the data via the browser panel.


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 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.


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 that contains numerous global, regional, and local CRSs. An example of a commonly used EPSG code is 4326, which refers to WGS 84. The EPSG online registry is available at

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

  1. Open the layer's properties by either navigating to Layer | Properties, or by right-clicking on the layer in the Layers panel
  2. Choose Source from the context menu
  3. If the layer's CRS is not set or is incorrect, click on the globe at the end of the drop-down menu, and select the correct CRS

Working with tables

There are two types of tables 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 Layer | Add Layer | Add Vector 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 tables 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. Beneath the title bar is 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, which 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 joining
  • There 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 Layer | Add Layer | Add Vector 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:

  1. Select the GIS layer in the Layers panel that will receive the new data from the join.
  2. Navigate to Layer | Properties and choose the Joins tab.
  3. Click on the Add join button (the one with a green plus sign).
  4. 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.


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.

  1. 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 allows 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.
  2. 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 matches the value in the Target field.
  3. The additional data from the join can be used to query the data and style the data.
  4. 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).


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 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 tool will change to the appropriate geometry depending on whether a point, line, or polygon layer is selected. Points and vertices of lines and polygons are created by clicking on the Map Canvas. To complete a line or polygon feature, right-click. After adding a feature, you will be prompted to enter the attributes.
  • The Vertex Tool lets you move individual feature vertices. Click on a feature once with the tool to select it, and the vertices will change into red boxes. Click again on an individual vertex to select it. The selected vertex will turn into a dark-blue box. Now, the vertex can be moved to the desired location. Additionally, edges between vertices can be selected and moved. To add vertices to a feature, simply double-click on the edge where you want the vertex to be added. Selected vertices can be deleted by pressing the Delete key on the keyboard.
  • Modify the attributes of all selected features simultaneously, which allows you to set a value for all the selected features:
  • Features can be deleted, cut, copied, and pasted using the Delete Selected, Cut Features, Copy Features, and Paste Features tools.


As of version 3 of QGIS, how snapping is carried out has changed. Snapping is a specified distance (tolerance) within which vertices of one feature will automatically align with vertices of another feature. Once enabled, users can set which layers are to be used to snap against; if vertex, vertex and segments, or just segments, are to be snapped against; and the distance from which snapping will occur. Additional topological and tracing functions have been added to further enhance the snapping toolset:


Styling vector data

When you load spatial data layers into QGIS Desktop, they are styled with a random single symbol rendering. To change this, right-mouse click on the layer and choose properties, and, in the context menu, click on Symbology.

There are several rendering choices available from the menu in the top-left corner, which are as follows:

  • Single Symbol: This is the default rendering in which one symbol is applied to all the features in a layer.
  • Categorized: This allows you to choose a categorical attribute field to style the layer. Choose the field and click on Classify and QGIS will apply a different symbol to each unique value in the field. You can also use the Set column expression button to enhance the styling with a SQL expression.
  • Graduated: This allows you to classify the data by a numeric field attribute into discrete categories. You can specify the parameters of the classification (classification type and number of classes) and use the Set column expression button to enhance the styling with a SQL expression.
  • Rule-based: This is used to create custom, rule-based styling. Rules will be based on SQL expressions.
  • Point Displacement: If you have a point layer with stacked points, this option can be used to displace the points so that they are all visible.
  • Point Cluster: This option groups clusters of points together at a specified distance. This will be covered more in later chapters.
  • Inverted Polygons: This is a new renderer that allows a feature polygon to be converted into a mask. For example, a city boundary polygon that is used with this renderer would become a mask around the city. It also allows the use of Categorized, Graduated, and Rule-based renderers and SQL expressions.
  • Heatmap: This allows you to create a heat map rendering of point data based on an attribute.
  • 2.5D: This allows you to extrude data into a 2.5D space. A common use case is to extrude building footprints upward, creating an almost 3D rendering.

The following screenshot shows the symbology properties available for a vector line layer:


For a given symbol, you can work with the first level, which gives you the ability to change the transparency and color. You can also click on the second level, which gives you control over parameters such as fill, border, fill style, border style, join style, border width, and X/Y offsets. These parameters change depending on the geometry of your layer. You can also use this hierarchy to build symbol layers, which are styles built from several symbols that are combined vertically.

Styling raster data

You also have many choices when styling raster data in QGIS Desktop. There is a different choice of renderers for raster datasets, which are as follows:

  • Multiband color: This is for rasters with multiple bands. It allows you to choose the band combination that you prefer.
  • Paletted / Unique values: This is for singleband rasters with an included color table. It is likely that it will be chosen by QGIS automatically, if this is the case.
  • Singleband gray: This allows a singleband raster or a single band of a multiband raster to be styled with either a black-to-white or white-to-black color ramp. You can control contrast enhancement and how minimum and maximum values are determined.
  • Singleband pseudocolor: This allows a singleband raster to be styled with a variety of color ramps and classification schemes.
  • Hillshade: Used mainly against Digital Terrain Data, this function allows to you add hillshade relief to the layer by changing the angles/direction of sunlight.

The following is a screenshot of the Symbology tab of a raster file's Layer Properties, showing where the aforementioned style choices are located:

Blending modes

The blending modes allow for more sophisticated rendering between GIS layers. Historically, these tools have only been available in graphics programs and they are a fairly new addition to QGIS. Previously, only layer transparency could be controlled. There are now 13 different blending modes that are available: Normal, Lighten, Screen, Dodge, Addition, Darken, Multiply, Burn, Overlay, Soft light, Hard light, Difference, and Subtract. These are much more powerful than simple layer transparency, which can be effective, but which typically results in the underneath layer being washed out or dulled. With blending modes, you can create effects where the full intensity of the underlying layer is still visible. Blending mode settings can be found in the Symbology menu under Layer Properties in the Layer Rendering section (for vectors) and Color rendering section (for rasters).


Composing maps

With QGIS, you can create maps that can be printed or exported to image and graphic files. Prior to version 3, in order to create maps, you used the Print Composer; this has now changed its name to Layouts. To create a new Layout, click on Project | New Print Layouts. Give the new layout a name, click on OK, and the composer window will open. From this point on, you can access the new layout from Project | Layouts.

The composer presents you with a blank sheet of paper upon which you can craft your map. Along the left-hand side, there are a series of tools on the Composer Items toolbar. The lower portion of the toolbar contains buttons for adding map elements to your map. These include the map body, images, text, a legend, a scale bar, graphic shapes, arrows, attribute tables, and HTML frames. Map elements become graphics on the composition canvas. By selecting a map element, graphic handles will appear around the perimeter. These can be used to move and resize the element. The upper portion of the Composer Items toolbar contains tools for panning the map data, moving other graphic content, and zooming and panning on the map composition.

The majority of the map customization options can be found in the composer tabs. To specify the sheet size and orientation, use the Composition tab. Once map elements have been added to the map, they can be customized with the Item properties tab. The options available on the Item properties tab change according to the type of map element that is selected. The Atlas generation tab allows you to generate a map book. For example, a municipality could generate an atlas by using a map sheet GIS layer and specifying which attribute column contains the map sheet number for each polygon. The Items tab allows you to toggle individual map elements on and off.

The toolbars across the top contain tools for aligning graphics (the Composer Items actions toolbar), navigating around the map composition (the Paper Navigation toolbar), and tools for managing, saving, and exporting compositions. Maps can be exported as images, PDFs, and SVG graphic files. To export the map, click on the Composer menu and select one from among Export as image..., Export as SVG..., or Export as PDF... depending on your requirements. The following is a screenshot showing the Layout window:


Adding functionality with plugins

There are so many potential workflows, analysis settings, and datasets within the broad field of GIS that no out-of-the-box software could contain the tools for every scenario. Fortunately, QGIS has been developed with a plugin architecture. Plugins are add-ons to QGIS that provide additional functionality. Some are written by the core QGIS development team, and others are written by QGIS users.


You can also browse the QGIS Python Plugins Repository at

You can explore the QGIS plugin ecosystem by navigating to Plugins | Manage and Install Plugins. This opens the Plugins Manager window (shown in the following screenshot), which will allow you to browse all plugins, those that are installed, those that are not installed, plugins that are newly available, and adjust the plugin manager settings. If there are installed plugins with available upgrades, there will also be an Upgradable option. The search bar can be used to enter search terms and find available plugins related to the topic. This is the first place to look if there's a tool or extra type of functionality that you need! To install a plugin, simply select it and click on the Install Plugin button. Installed plugins can be toggled on and off by checking the box next to each:

You will be notified by a link at the bottom of the QGIS Desktop application if there are updates available for your installed plugins. Clicking on the link will open the Plugins Manager window, where the Upgrades tab will allow you to install all or some of the available updates. Plugins themselves may show up as individual buttons, toolbars, or as items under the appropriate menu, such as Plugins, Vector, Raster, Database, Web, or Processing. The following information box describes a great plugin for adding base maps.


To add a basemap to QGIS, enable the Quick Map Services plugin. Once it's installed, it appears as an item on the Web menu. You can configure it to include more map services. From the menu bar, choose Web | QuickMapServices | Settings. Click on the Contributed Services tab, and click the Get contributed pack button. At this point, it will allow you to add base maps from OpenStreetMap, Google Maps, Bing Maps, Map Quest, OSM/Stamen, Apple Maps, and several more. This plugin requires an internet connection.

Custom QGIS variables

A new feature of QGIS since version 2.12 is custom variables. Variables can be set at several different scopes or levels:

  • Global
  • Project
  • Layer

Global variables are available at the application level in any QGIS Desktop instance. These can be managed from Settings | Options | Variables. Examples of what you might set as global might be a company/organization name that you can then later use in expressions, Print Layouts, or when editing data to autopopulate fields. 

Project variables are available throughout a given project. These can be set from the Project Properties window on the Variables tab. Examples may include project names, reference numbers, or client names.

Layer level variables are available from Layer Properties on the Variables tab, and are available only for that layer.

In each instance, variables can be added using the green plus button found in the bottom-right corner of the variables screens.

The other important aspect of these variables is that they cascade from most specific scope to least specific scope. In other words, @my_var set at the Global level will be overwritten by @my_var set at the Project level.

Variables are still a very new feature, but have a lot of potential for creating more efficient workflows.Once you begin using them, you will undoubtedly discover many other use cases.



This chapter provided a refresher on the basics of QGIS and a look at some of the new functionality of 3.x. We covered how to install the software on several platforms. We then covered how to load vector, raster, and database data layers. Next, you were shown how to work with coordinate reference systems and style data. We covered the basics of working with tables, including how to perform a table join. The chapter concluded with a refresher on composing maps, how to find, install, and manage plugins, and a primer on QGIS custom variables.

The next chapter will cover styling vectors and raster data. Now that you have had a refresher on the basics of QGIS, it is time to learn how to expand your work to include spatial databases. In Chapter 3, Creating Spatial Databases, you will learn how to create and manage spatial databases within QGIS.

About the Authors
  • Shammunul Islam

    Shammunul Islam is a consulting spatial data scientist at the Institute of Remote Sensing, Jahangirnagar University, and a senior consultant at ERI, Bangladesh. He develops applications for automating geospatial and statistical analysis in different domains such as in the fields of the environment, climate, and socio-economy. He also consults as a survey statistician and provides corporate training on data science to businesses. He holds an MA in Climate and Society from Columbia University, an MA in development studies, and a BSc in statistics.

    Browse publications by this author
  • Simon Miles

    Simon Miles is a GIS developer working for the Royal Borough of Windsor and Maidenhead, and has been working in the GIS industry since 2003. He always works using open source technologies. His main kit includes QGIS, PostGIS, Python, GDAL, Leaflet, JavaScript, and PHP. His main focus is on digital delivery/transformation, chiefly through the consolidation of data, applications, and legacy systems, and replacing these with APIs and web applications. In 2013, He helped to establish the UK QGIS user group, which holds regional meetings two or three times a year.

    Browse publications by this author
  • Kurt Menke, GISP

    Kurt Menke, a certified GIS Professional (GISP), has been working in the GIS field since 1997. Prior to this, he worked as a professional archaeologist for 10 years in the American Southwest. He earned a master's degree (MA) in Geography from the University of New Mexico in 2000. That same year, he founded Bird's Eye View ( to apply his expertise with the GIS technology to the World's mounting ecological and social problems. Towards this end, Mr. Menke's work focuses largely on wildlife conservation and public health. His specialties are spatial analysis, modeling, and cartography. He is a longtime advocate of FOSS4G. He began writing MapServer applications in 2001 and has been using QGIS since 2007. He is one of the coauthors of the curriculum at the FOSS4G Academy

    Browse publications by this author
  • Richard Smith Jr., GISP

    Richard Smith Jr., GISP, is an asst. professor of geographic information science in the School of Engineering and Computing Sciences at Texas A&M University, Corpus Christi. He has a Ph.D. in geography from the University of Georgia, MSc in computer science, and BSc in geographic information science from Texas A&M University, Corpus Christi. He researches in cartography, systems integration, and the use of geospatial technology for disaster response. He is an advocate for FOSS4G and building a FOSS4G curriculum. He is a co-author of the FOSS4G Academy.

    Browse publications by this author
  • Luigi Pirelli

    Luigi Pirelli is a QGIS developer and software analyst with a degree in computer science from Bari University. He has worked in the Satellite Ground Segment and Direct Ingestion for the European Space Agency. He is involved in GFOSS world, contributing in QGIS, GRASS, & MapServer core, and developing QGIS plugins. Luigi is the founder of the OSGEO Italian local GFOSS chapter. He has taught PyQGIS, delivered training from basic to advanced levels, and supported companies to develop their own QGIS plugins. He founded a local hackerspace He likes training groups on conflict resolution. He contributed to the Lonely Planet guide Cycling Italy.

    Browse publications by this author
  • John Van Hoesen, GISP

    John Van Hoesen, GISP, is an associate professor of geology and environmental studies at Green Mountain College in rural west-central Vermont, USA. He has an MS and a Ph.D. in geology from the University of Nevada, Las Vegas. He is a certified GISP with a broad background in the geosciences and has used some flavor of GIS to evaluate and explore geological processes and environmental issues. John has taught graduate, undergraduate, and continuing education courses using some variants of FOSS GIS since 2003.

    Browse publications by this author
Latest Reviews (1 reviews total)
Recommended For You
Mastering Geospatial Development with QGIS 3.x - Third Edition
Unlock this book and the full library FREE for 7 days
Start now