QGIS is a desktop geographic information system that facilitates data viewing, editing, and analysis. Paired with the most efficient scripting language—Python, we can write effective scripts that extend the core functionality of QGIS.
Based on version QGIS 2.18, this video will teach you how to write Python code that works with spatial data to automate geoprocessing tasks in QGIS. It will cover topics such as Creating Dynamic Maps.
You will also learn to compose static maps, interact with users.
Following this, you will work through recipes that will help you compose static maps, create heavily customized maps, and add specialized labels and annotations. As well as this, we’ll also share a few tips and tricks based on different aspects of QGIS.
About the Author
Joel Lawhead is a PMI-certified Project Management Professional (PMP), a certified Geographic Information Systems Professional, an award-winning firm specializing in geospatial technology integration and harsh-environment engineering. Joel builds geospatial systems for US government agencies, including NASA, NOAA, the US Department of Homeland Security, and the military. He also works with private organizations, including the National Oceans and Applications Research Center (NOARC) and The Ocean Cleanup. He has authored other books with Packt Publishing, including Learning Geospatial Analysis with Python, QGIS Python Programming Cookbook, and Learning Geospatial Analysis with Python, Second Edition. His cookbook recipes have been featured in two editions of the O’Reilly Python Cookbook.
Joel began using Python in 1997 and combined it with geospatial software development in 2000. He is also the developer of the widely used open source Python Shapefile Library (PyShp) and maintains the geospatial technical blog and Twitter feed, @SpatialPython, discussing the use of Python within the geospatial industry.
In 2011, Joel reverse-engineered and published the undocumented shapefile spatial indexing format and assisted fellow geospatial Python developer, Marc Pfister, in reversing the compression algorithm, allowing developers around the world to create better integrated and more robust geospatial applications involving shapefiles.
In 2002, Joel received the international Esri Special Achievement in GIS award for his work on the Real-Time Emergency Action Coordination Tool (REACT) for emergency management using geospatial analysis.
Maps in QGIS are controlled through the map canvas. So in this video, we'll be accessing the canvas and then will be checking one of its properties to ensure that we have control over the object.
Changing map units, is a very common operation, depending on the purpose of your map. In this video, we'll be reading the map units used by QGIS and then change them for our project.
For many GIS operations, you need to loop through the map layers to look for specific information or to apply a change to all the layers.In this video, we'll be looping through the layers and get information about them.
The symbols describe properties, including color, shape, size, and line width. In this video, we’ll be loading a vector layer, change its symbology, and finally refresh the map.
In this video, we will load a polygon layer onto the map, and then interactively change it to just an outline of the polygon.
Filled marker symbols allow for an endless set of options for rendering a polygon. In this video, we'll do a very simple filled marker symbol that paints a polygon with stars.
A color ramp allows you to render a raster using just a few colors to represent different ranges of cell values that have a similar meaning in order to group them. The approach that will be used in this video is the most common way to render elevation data.
In this video, we'll load some points into QGIS from a CSV file and use one of the columns to determine the color of each point.
The true power of QGIS symbology lies in its ability to stack multiple symbols in order to create a single complex symbol. In this video, we'll merge two symbols to create a single symbol and begin unlocking the potential of complex symbols.
TrueType fonts are scalable vector graphics that can be used as point markers. In this video, we'll create a symbol of this type.
Font markers open up broad possibilities for icons, but a single-color shape can be hard to see across a varied map background. In this video, we'll use font marker symbol methods to place an outline around the symbol to give it contrast and, therefore, visibility on any type of background.
Sometimes you also need to convey a direction along a line. In this video, we'll symbolize some line features showing historical human migration routes around the world.
Graduated vector layer symbol renderer is the vector equivalent of a raster color ramp. In this video, we'll render a graduated symbol using a polygon shapefile.
A categorized vector layer symbol allows you to create distinct categories with colors and labels for unique features. In this video, we'll categorize a vector layer into three different categories.
Live layer effects provide advanced cartographic effects for QGIS maps. In this video, we'll add the inner glow and drop shadow live layer effects to a polygon layer.
Shapeburst fills are a type of symbol layer that allow you to create buffered gradient fills. In this video, We'll use a land shapefile and a water shapefile, and in the water feature, we'll color it to give the illusion of deeper water in the middle.
Map bookmarks allow you to save a location on a map in QGIS, so you can quickly jump to the points you need to view repeatedly without manually panning and zooming the map.
Map bookmarks store important locations on a map, so you can quickly find them later.
PyQGIS supports scale-based visibility to programmatically set the scale range, in which a layer is displayed. In this video, we'll investigate scale-dependent layers.
Scalable Vector Graphics (SVG) are an XML standard that defines vector graphics which can be scaled at any resolution. In this video, we'll use Python to apply one of the SVG symbols included with QGIS to a point layer.
QGIS has the ability to use dynamic pie charts as symbols describing the statistics in a given region. In this video, we'll use pie chart symbols on a polygon layer in QGIS.
The 2.5D renderer is a powerful new visualization for QGIS, which allows you to present buildings as three-dimensional shapes from a single angle. In this video, we'll render a small set of building footprints in 2.5D, with height values set as a shapefile attribute.
A tiled map service allows you to efficiently display large raster data sets from web services. Also There are two types of Esri services: ArcGIS map services, which provide tiled map layers, and ArcGIS feature services, which provide vector layers. So in this video, we'll load the Open Street Map tiled map service and create a map with one of each type of Esri service.
Once your map layers are styled, the next step to creating a complete map is labeling features. We'll explore the basics of labeling in this video.
Null symbols are a tool that allow you to have a layer without any symbology In this video, we'll load a point layer and label it, but use null symbology.
Map layer transparency allows you to change the opacity of a layer, so the items behind it are visible to some degree.
In order to turn a dynamic GIS map into a static map image or document, you must create a renderer to freeze the map view and create a graphic version of it. In this video, we'll render a map to a JPEG image and save it.
The QGIS Map Composer allows you to combine a map with non-spatial elements that enhance the understanding of the map. In this video, we'll be creating a basic map composition.
The Q g s Composition object allows you to place arbitrary text anywhere in the composition. In this video, we'll demonstrate how to add a label to a map composition.
In this video, we'll create a scale bar that increments in kilometers then we will be adding an arrow element that points to the north and finally we'll add a simple logo to the map.
A map legend decodes the symbology used in a thematic GIS map for the reader. Legends are tightly integrated into QGIS, and in this video, we'll add the default legend from the map to the print composition and we'll add two layers set up the legend to run horizontally across the top of the map.
The QGIS composer has an object for drawing and styling nonspatial shapes, including rectangles, ellipses, and triangles. In this video, we'll add some rectangles filled with different colors, which resemble a simple bar chart; then we will add grid for reference purpose. And finally add the table to the composition.
Exporting a map as an image removes all of its spatial information. However, you can create an external text file, called a world file, which provides the georeferencing information. In this Video, we'll export a map composition as an image and create a world file along with it.
Saving a project automatically can be useful for auto save features. In this video, we'll save a QGIS project to a .qgs project file.
Loading a project will set up the map and project settings for a previously saved project within QGIS.This video demonstrates you to load a project from a .qgs XML file.
Log files provide a way of tracking exactly what is going on in a Python plugin or script. These log messages make troubleshooting easier. In this video, we'll demonstrate two methods used for logging. actual log files and QGIS Log Messages Panel
In this video, we'll create a simple information dialog, a warning dialog to notify a user when an issue is detected, and an example of error dialog.
A progress bar is a dynamic dialog that displays the percentage of completion bar for a running process that the user must wait for before continuing. In this video, we'll create a simple progress dialog based on a timer.
In this video, we demonstrate one of the simplest methods used for accepting input from a user: a text input dialog. And then we'll create a file dialog and print the chosen filename to the console.
In this video we'll create a simple combobox, then we will proceed to create radio buttons then we'll create a dialog with checkboxes and some textboxes.
The status bar in QGIS displays a variety of information in all sorts of contexts. In this video, we'll print the current time to the status bar.
In this video we'll push a simple message to the status bar and then we'll display a progress bar in the message bar.
Tabs provide titles at the top of the window, which present an individual widget layout for each title when clicked. In this video, we'll create a simple tabbed interface.
Wizard is a series of dialogs that lead the user through a sequence of steps. In this video, we'll create a simple three-page wizard to collect some information from the user and display it back to them.
Qt has a window setting called hint, which allows you to force a window to stay on top. This type of dialog is called a modal dialog. In this video, we'll create a message dialog using hint.
NDVI is used to detect green vegetation in an area of interest. So here in this video, we will use Python to control the QGIS raster calculator in order to create an NDVI using a multispectral image of a farm field.
Geocoding is the process of turning an address into earth coordinates. In this video, we'll use this plugin to programmatically geocode an address.
The vector footprint files can be easily loaded in QGIS or served over the Web. This video demonstrates a method to create a footprint vector from a directory full of raster files.
Network analysis allows you to find the most efficient route between two points along a defined network of connected lines. In this video, we'll use a generic line network to perform analysis using the Dijkstra algorithm, to find the shortest path.
Street routing has now become so commonplace that we take it for granted. So here in this video we will perform routing operations in QGIS, we'll use the QGIS GeoSearch plugin.
QGIS has the ability to connect to a GPS .In this video, we'll use the QGIS API to process NMEA sentences and update a point on a global map.
Nearest neighbor analysis relates one point to the nearest point in one or more datasets. In this video, we'll relate one set of points to the closest point from another dataset.
In this video, we will we'll convert a LAS point cloud file to a Digital Elevation Model (DEM). We’ll use earthquake point data to create a heat map of the impact of an earthquake and illustrate population density in some US census bureau tracts.
Collecting field observation data from the field into a GIS required hours of manual data entry. n this video, we'll use a simple GeoJSON-based framework to enter information and a map location from any Internet-connected device with a web browser to update a map in QGIS.
A common geospatial workflow is to assign raster values to a coincident vector layer. This video will use this concept to illustrate the steepness of a road using color by mapping values to the road vector from a slope raster.
In this video, we'll use EXIF tags to create locations on a map for some photos and provide links to open them.
In this video, we'll do a simple difference change detection on two images, which are several years apart, to see the differences in urban development and the natural environment.
A common task in digitizing is to outline buildings in an image to make footprints for urban analysis. In this video we'll automatically transform some non-rectangular polygons into rectangles using a simple algorithm.
In this video, we'll load a dataset that has multiple time steps, and use the well-designed TimeManager plugin to step through the data time steps in an animation.
In this video we are going to create Internet web map tiles from our QGIS map.
In this video demonstrates to use a service named geojson.io, which serves vector layers online which you can upload from QGIS using Python.
This video demonstrates how to use a rule-based renderer to color code a layer based on an attribute.
Layer styling is one of the most complex aspects of the QGIS Python API. Once you've developed the style for a layer, it is often useful to save the styling to the QGIS Markup Language (QML) XML format.
Python uses None objects of type None instead of NULL values. In this video, we'll explore the implications of QGIS NULL values in Python.
A simple Python QGIS query engine, uses generators to make fetching features from QGIS layers easier. We'll use this engine in this video, to query a layer.
Thematic maps often use a color ramp based on a single color to show data density. In this video, you use some bear-sighting data to show concentrations of bears over an area.
The geo_interface is a newer protocol to provide a string representation of geographical data. In this video we will use this to to provide a code snippet, which you can put at the beginning of your Python scripts to retrofit QGIS feature.
The processing framework is mostly very consistent, however the names of output variables vary. So in this video, we'll use PyQGIS to programmatically get the output variable name.
You can generate points within a polygon fairly simply using a point in polygon method. In this video, we will demonstrate 2 methods to generate points along line.
Expressions are a kind of mini-programming language or SQL-like language found throughout different QGIS functions. Here in this video, we will filter labels using expressions from within Python.
If you need to calculate the total of a given dataset property such as length, the easiest thing to do is just use Python. In this video, we'll total the length of all of the railways in a dataset.
Sometimes, you want to display a different coordinate system for the mouse coordinates in the status bar. With this video, you can set a different coordinate system without changing the data.
OpenStreetMap has an API called Overpass that lets you access OSM data dynamically. In this video, we'll add some OSM tourism points of interest to a map.
QGIS displays data in a two dimensions even if the data is 3D. In this video, we'll use the Qgis2threejs plugin to display QGIS data in 3D in a browser.
Since the release of Google Earth, spinning globe applications are a useful and popular method of geographical exploration. In this video, we'll display a layer in Google Earth.
QGIS increasingly supports cartographic visualizations that go beyond GIS analysis. In this video we'll animate hub lines generated from the nearest neighbor analysis of UFO sightings in major cities.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.