Lab01_Intro_QGIS
Lab01_Intro_QGIS
Introduction to QGIS
What You’ll Learn: This is a basic introduction to starting QGIS, adding data, changing symbols,
creating maps, and topology (developed using QGIS version 3.34.10). .
Data: for this exercise data is in the Lab01_Intro_QGIS_DATA zip folder. Videos for downloading
QGIS, getting data ready, and playlist for lab 1 can be found in the Mapeez YouTube channel:
https://youtube.com/playlist?list=PL1JFwtT2Vr4bJIeMuo6QSdxiI-l6yFSs1
What You’ll Produce: Three maps: one of lakes and roads, one of wetlands, and an inset map with
raster and vector data.
Background: This is the first in a series of introductory exercises for QGIS, versions 3.x. Most were
originally written under version 3.10, and updated for version 3.36. These are practical skills that
complement the theory and practice of GIS described in the textbook GIS Fundamentals: A First Text
on Geographic Information Systems, by Paul Bolstad and Steven Manson. You should read the first
two chapters in that book before doing this exercise.
There are companion videos and playlists on the YouTube channel, Mapeez, with the main channel
video page here:
https://www.youtube.com/@mapeez7614/videos
Videos may be bit of a jumble on the main page because it displays them by latest, most popular, or
oldest, or other characteristics, depending on settings.
We organize the videos by playlists, with a playlist for each lab exercise. Playlist names correspond
more or less to each exercise, e.g., “Lab 1 QGIS3.x”. The videos referred to in this lab are in the
QGIS3-Lab1 playlist. There are many other helpful YouTube channels for QGIS, for example, those
by Klas Karlsson, Hans van der Kwast, and burdGIS.
https://www.youtube.com/channel/UC27rva6Odkr0J2tIuPodGaA
We assume you have a functioning copy of QGIS running on your computer. If you don’t, please see
the video on the Mapeez channel on YouTube, named DownloadInstallQGIS3.x on loading QGIS,
or visit the www.qgis.org website and follow the links to install. You have a copy of the needed data
files, from an instructor or downloaded through links www.GISFundamentals.org web site. In the
subsequent instructions, we will write “click” when we mean a left-click on the mouse button. We will
explicitly identify those clicks of the mouse button that need to be right clicks.
1.Sep.24 1
QGIS 3.x Exercises Introduction to QGIS
Part 1: Starting QGIS, adding data, and creating your first map
First, find the QGIS icon, shown to the right. The icon is often located as either:
a) A desktop or taskbar shortcut
b) On a Microsoft Windows Operating System, there may be a QGIS folder in the
programs menu, opened by clicking the windows button in the lower part of the screen.
Note that in Windows, QGIS may often by found by left clicking on the Start button in the lower left of
the screen and selecting the QGIS 3.X.X folder. On a Mac, QGIS is usually found in the Applications
Folder. The containing folder name and configuration on both operating systems depend on how the
system was setup at install, so QGIS may be in different folders and you may have to look a bit.
Double click on the QGIS icon and be patient while a start banner displays. You may first see a
user tip, if so, dismiss it.
The main QGIS window should appear, similar to that displayed below. Note there is Table of
Contents pane that QGIS calls a Layers pane, typically on the left side of the main window. This lists
the layers you have currently loaded in your project. There is a Data pane, which displays your layers,
as well as various tool bars.
One of the most used icons is for adding data layers (Open Data Source Manager), noted in the
graphic below:
Data Pane
Table of Contents
1.Sep.24 2
QGIS 3.x Exercises Introduction to QGIS
A Click on the Open Data Source Manager icon will open a window, allowing you to identify a data
type and file. We will select a Vector data type, and click on the Browse button at the right end of the
Source Type box:
You should then see a navigation window similar to that shown below.
Note that the general form of the navigation/selection window will vary depending on your operating
system. A MS Windows screen is shown above, and a Mac directory shown on the next page, but
even these will vary depending on you operating system settings and version. The important thing to
note is that you should get a list of files/folders to navigate.
1.Sep.24 3
QGIS 3.x Exercises Introduction to QGIS
Note that for both operating systems, we have selected the lakes.shp file. The .shp extension signifies
a shapefile, a common spatial data file format. Data for shapefiles are saved in a cluster of files, e.g.,
lakes.shp, lakes.dbf, lakes.sbn, and others specify a spatial data layer. We must select the lakes.shp
file for display. In both Windows and Mac we click on the lakes.shp file to selection it, then the Open
button to open the file. In these labs we will specify this action by lakes.shp fileà Open button. This
should close the file display window and go back to the Data Source selection window. Click Add in
the lower right to display the data. Click Close to hide the Data Source Manager window.
1.Sep.24 4
QGIS 3.x Exercises Introduction to QGIS
QGIS allows you to change the magnification and area that you view in your data pane. There is a
cluster of zoom buttons (see below). They are typically along the top of the main window, but
because the toolbars are “dockable”, they may be elsewhere.
If you hold the cursor near each icon for a few seconds, descriptive text should appear, with the
name/brief description of the display function. Click on the Zoom In and Zoom Out icons (magnifying
glasses) and Pan Map icon (hand) to change cursor function. Clicking on the Zoom In icon (plus/+
sign magnifying glass) changes it to a “zoom in” cursor. A click on the data pane will zoom in on a
point. You can also click and hold/drag to define an area to zoom in to.
The Pan Map button allows you to click/drag to reposition views of displayed layers. There is also a
three-arrow zoom button that zooms to the full “Extent” of your data. There is a magnifying glass with a
yellow square behind that zooms to selected features and one with a gray square behind that zooms
to a layer selected in the Table of Contents. There are also two buttons with carets that zooms back
and forth among previous zoom levels.
Clicking on the carets will show the missing buttons (e.g., for the zoom menus).
1.Sep.24 5
QGIS 3.x Exercises Introduction to QGIS
Layer Symbology
Change the lake symbol to blue via the Color dropdown menu and other controls on the right of this
window. Left click on the Apply and OK.
Repeat this process for the Roads layer, making the roads black and Width approximately double
the original thickness. Click Apply and OK.
1.Sep.24 6
QGIS 3.x Exercises Introduction to QGIS
Creating a Map
Name the layout Lab1Layout and click OK. This will display a new window with tools along the top
and left sides of the panel for creating your map, a large (blank) page window on the center left, and a
set of tabs to adjust properties for items on the center right (see below).
9 7
8
2
6
3 1
4
1. Select the paper size (Right click on the pageà Page Propertiesà Adjust the values for
page size in the Item Properties right panel).
2. Add a new map (select Add Map iconà click and drag a box to make a map area).
3. Add a title (select Add Label iconà click and drag to create a text boxà type in textà adjust
font properties in the right Item Properties panel).
1.Sep.24 7
QGIS 3.x Exercises Introduction to QGIS
4. Add a legend (select Add Legend iconà click and drag to create a legend).
5. Add a scalebar (select Add Scale Bar iconà click and drag to create a scale bar).
6. Add a north arrow (select Add Imageà click and drag to create an image box, select an
image of a north arrow in the Item Properties, SVG browser panel. This is a bit complicated,
you might wish to view the video referenced above)
When you are done adding and adjusting map elements, you can (see video) export map as pdf, print
the map; and then save the map
Create a map that looks something like that in the figure below and export it as a pdf.
1.Sep.24 8
QGIS 3.x Exercises Introduction to QGIS
QGIS project files have a .qgs extension. These project files do not save any real data. They only
contain instructions on how to display data from various sources, how layouts are composed, changed
settings for project, and other information about this particular.
Project files save the directory/files where your data are stored, e.g., C:\myclasswork\lakes.shp. They
save only the path to the file. This can present some problems when moving projects to other
computers. The drive letters or directories to files may change between systems. If you copy a project to
another computer and save it on a different folder on a D: drive, e.g., in D:\paulproj\lakes.shp, the path
to data will no longer be valid and the data won’t display. You can try to recreate the exact drive/path
locations for all data on different computers, but this can be burdensome. We’ll show you how to
avoid some of these problems.
Save your old project and create a new QGIS project, then click on the New Project button in the
upper-left corner of the QGIS menu:
Right click on the name roads in the table of contents windowà click on Properties at the bottom.
A new window will open and click on the Information option. Look at the layer Path found listed
second in the main window. Note that there is a path that may start with a drive letter, something like
E:\L1\roads.shp or it may start with a directory like /Volumes/HD/QGIS3/Data/roads.shp, or an even
longer path, as shown below.
The Path is recorded for each data set within the QGIS project. This is where the project looks to find
data each time you open any previously created and saved project. This path is the drive and
sequence of subdirectories/folders that lead to the data file. Your path will be different, depending on
the directory you are using to store your data, but the important point is that if you are using a fixed
absolute path, your QGIS project will look along the entire path for the data, and this can cause
problems.
1.Sep.24 9
QGIS 3.x Exercises Introduction to QGIS
As noted above, a fixed path storage arrangement isn’t very flexible or portable. A fixed path isn’t a
problem if you always work on the same computer with fixed drives, and you never change the
subdirectories, but that often isn’t the case. If you move your project to a different computer, or add a
drive to a computer, or work on virtual drives, you may well lose the connection between project and
data, and when you open the project, some or all of your data won’t appear.
There should be a ribbon across the top or your screen, or the window in which QGIS is open (it
depends on operating system and
configuration).
On a Mac using the iOS operating system it will look like above.
Of course, sometimes it is not possible to save all the data and your project in the same directory. You
may have large datasets organized in a directory structure for easy updates, with data on different
drives, and so don’t want to copy them to the same location as this would take up too much space,
meaning a drive letter or complex path is inevitable for one of the data sets. Or you make work for a
large organization, with data on linked, shared, or on network drives with different drive letters when
you move between computers. However, when working on stand-alone projects, or with smallish data
sets, it is best practice to have the project file (.qgs) and the data in the same directories, are as close
as possible in the directory tree.
1.Sep.24 10
QGIS 3.x Exercises Introduction to QGIS
Manipulating Symbology
Remove the roads layer (right click on the name in the Table of Contentsà click on Remove Layer…
in the dropdown menu). Add the layer wet_land.shp from your data directory. This layer shows
polygons that depict the wetlands of the Hugo USGS quadrangle, in Minnesota.
After adding the data, right click the name of the layer wet_landsàselect Properties. This opens a
Layer Properties window, you saw earlier. Now we’ll color the wetland polygons by different wetland
categories (video QGIS 3x Categorized Symbols, on Mapeez in YouTube).
1.Sep.24 11
QGIS 3.x Exercises Introduction to QGIS
1.Sep.24 12
QGIS 3.x Exercises Introduction to QGIS
Recolor the wetlands layer using the Layer Properties Symbology menu. Base the colors on the
WETLAND_TY category. Since the U category is the background area, color this with some light
color. The L category is lakes, make these a light blue.
Color each of the remaining categories with distinct colors for each of the wetland types, so that your
data looks something like the panel on the right.
1.Sep.24 13
QGIS 3.x Exercises Introduction to QGIS
You don’t need to use exact colors, except for blue lakes, and light-colored uplands, as noted above.
Create a layout, and add your layers map, a legend, title, scale bar, and north arrow.
1.Sep.24 14
QGIS 3.x Exercises Introduction to QGIS
Save and close your previous project, open a new project, and add the following vector layers:
40_corners.shp
cl_roads.shp (not the roads.shp file)
streams.shp
Also add the raster layer named iverson_drg.img. Do this by clicking on the Open Data
Source iconà Raster.
Clicking on it will open an add layer menu similar to the vector layer style. Make sure you set the
iverson_drg.img layer that contains the data and not the other Iverson files with different file extensions
(e.g., not iverson_drg.rrd.img).
Notice that as you added layers, each new layer was placed on top of the preceding layers. When you
added the Iverson raster, it covered up the other layers.
You can move the raster layer, or any layer, by clicking on a layer in the table of contents pane and
dragging it up or down. When you let go of the click, the layer is repositioned. Move the iverson_drg to
the bottom of the list. You can now see the previously loaded vector layers. Reposition the
40_corners point layer to be on top of all the other layers.
Sometimes the entire name of a layer doesn’t appear in the Table of Contents pane, or we want
to resize the Table of Contents. We can do this by “hovering” your cursor over the border line
between the Table of Contents and the map data panes.
As you hover over the bar, a resize cursor should appear, two vertical lines with
horizontal arrows pointing outwards:
Clicking and holding when this cursor appears “grabs” the edge of the Table of Contents, and lets you
move it left or right to make it narrower/wider.
1.Sep.24 15
QGIS 3.x Exercises Introduction to QGIS
Resymbolize the 40_corners to red points, cl_roads to black lines, and streams to blue lines. Pan and
resize the extent to make your data pane appear similar to right. With lines, the menu includes a
Width option (set to 1 for the roads, and 0.5 for the streams).
The red circles are there to help learn the measure tool, described below.
1.Sep.24 16
QGIS 3.x Exercises Introduction to QGIS
Note the gravel pit and lookout tower circled in red in the image above. You may have to zoom in to
see these features on the iverson.drg map, the gravel pit is a bare area with a faint X to the right of the
label, and the tower is a very small circle with a dot in the middle, to the left of the label. If you zoom in
too far, the image appears pixelated, or blocky. If so, zoom out a bit, it will appear a bit better.
Pan and zoom until you can see both the gravel pit and lookout tower definition without too much
pixilation.
Use the measure tool, usually parked at the top right of the
main menu bar, to measure the distance between these two
features. Click on the triangle to the right of the Measure
Toolà select the Measure Line tool. Note that you can start
this tool with a shortcut keyboard sequence, Ctrl+Shift+M on
a MS Windows computer, and Command+Shift+M on a Mac.
There are many shortcuts to learn, although in general we
won’t introduce them to not create too much detail.
Note the first length number. This is the distance between the two features. The units are those of
the layer, meters in this example. We can set them to project units, but we’ll save that until after
you’ve learned about map projections.
If you had a multi-segment distance to measure, you would then move and click along the segments,
noting the length of each segment, and the total sum in the bottom window. You could start another
measurement via the New button in the bottom.
1.Sep.24 17
QGIS 3.x Exercises Introduction to QGIS
Close the measurement window. Create a map with a title, north arrow, legend, title, and description,
and export a PDF as before.
1.Sep.24 18
QGIS 3.x Exercises Introduction to QGIS
Sometimes you wish to show two maps on the same page, e.g., a larger overview map and an inset
map. We do this in QGIS by:
See the video Simple Inset Map in the QGIS 3.x Lab1 playlist on the Mapeez YouTube channel.
Note the changes in the second map in your layout may not appear on the print layout until after you
make it active, and perhaps zoom or pan at least a tiny bit.
As an exercise, start by creating a new QGIS project. Load the iverson_DRG.img. and then the
vegetation.shp data from the Lab 1 data directory.
Apply the above steps to create a two-panel inset map, similar to the map shown below. The inset
map in one single color, and the large map categorized color by the values of Cover_Type.
1.Sep.24 19
QGIS 3.x Exercises Introduction to QGIS
Topologies
QGIS supports topologies in a rudimentary way. As described in the readings, topologies are the
spatial relationships between objects, such as “overlaps,”, or “contained within.” When we check for
or enforce topologies, we’re trying to ensure correct spatial relationship, e.g., we might want to make
sure all our digitized power poles fall within our block or parcel polygons, and not on our street
polygons, or that all our river networks connect, or don’t have overshoots or dangling arcs. Many
spatial operations assume or require correct topology and will give wrong answers if there are
topological errors.
Start by loading the basins.shp shapefile. It contains the watershed outline for the Red Cedar and
Lower Chippewa rivers in western Wisconsin (video, Intro2Topology).
Next, find and click on the topology checker icon, it typically is placed on the main
menu frame. You may not initially be able to find the topology checker icon, though,
and so you may have to enable the topology checker before you use it.
1.Sep.24 20
QGIS 3.x Exercises Introduction to QGIS
The topology checker is a “plug-in,” a contributed extension that represents one of the strengths of
open source projects, because many developers can contribute to extending QGIS. It is a core plug-
in, so can’t be un-installed. You can check to see if it is activated by clicking on the Pluginsà Manage
and Install Plugins in the main QGIS bar at the top of the screen or primary window (Mac example,
right). Enter “topology” in the search bar. This should display the Topology Checker plugin, and you
should check it on if it is not checked. Go back to the base QGIS window, and look around for icon to
find the topology checker.
1.Sep.24 21
QGIS 3.x Exercises Introduction to QGIS
For example, if I click on the left-most button where it lists No layer, I’ll get a drop-down menu of the
currently displayed layers. I can then select basin. Clicking on the middle button will give a dropdown
list of rule choices. Select must not
overlap to ensure the polygons don’t
overlap each other in a layer. Click the
Add Rule button (plus sign), it will place
the rule in the pane below the buttons
and should look something like the figure
to the right.
I can add several rules to be checked at once. I find it clearer to only check the topology on one layer
at a time, rather than jumble up the display with rules and errors from multiple layers. It depends in
part on how many errors you expect per layer.
1.Sep.24 22
QGIS 3.x Exercises Introduction to QGIS
You’ll notice a border overlap in the lower left portion of the green polygon below.
Typically, you would note where the errors are and edit them manually or apply some sort of function
to remove the errors. We’ll cover editing in a later lab, for now just note the error identified by topology.
Remove the basin data layer, delete the rule from the
rule settings (click on a rule, then the Delete Rule
button (minus sign) in the Topology Rule Settings
window), then close the window.
1.Sep.24 23
QGIS 3.x Exercises Introduction to QGIS
Save and then Validate the rule for the entire extent.
How many of gap errors where rivers join can you find?
1.Sep.24 24