0% found this document useful (0 votes)
3 views

Lab01_Intro_QGIS

This document provides a basic introduction to QGIS 3.x, covering how to start the software, add data, customize symbols, and create maps. It outlines the exercises that will result in the production of three maps and emphasizes the importance of using relative paths for data management. Additionally, it includes links to instructional videos and resources for further learning on QGIS functionalities.

Uploaded by

Jeremy Kulm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab01_Intro_QGIS

This document provides a basic introduction to QGIS 3.x, covering how to start the software, add data, customize symbols, and create maps. It outlines the exercises that will result in the production of three maps and emphasizes the importance of using relative paths for data management. Additionally, it includes links to instructional videos and resources for further learning on QGIS functionalities.

Uploaded by

Jeremy Kulm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

QGIS 3.

x Exercises Introduction to 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:

Open Data Source Manager

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.

For efficiency, most future graphics will only show


examples for one operating system (MacOS or
Windows 10) and may switch back and forth.

Repeat the add data process, using the roads.shp


shapefile.

You should have a data pane that looks something


like the figure at right. Your colors will be different,
we’ll show you how to change symbology soon.

1.Sep.24 4
QGIS 3.x Exercises Introduction to QGIS

Panning and Zooming

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.

Also note that some of the buttons can be hidden


on the menu bar. Hidden buttons/icons are
indicated by double right carets at the right end of a
set of buttons (see right).

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

We can customize a layer’s


appearance. Double click on the
name of the lakes data layer in the
Table of Contents or right click on
the name and then scroll to near the
bottom of the dropdown menu and
select Properties.

The properties window will appear,


select on the Symbology option in
the left-most column (see right).
There is a video named QGIS 3.x
Simple Symbology on the YouTube
Mapeez Channel.

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

QGIS uses Layouts to create maps, typically


showing data, legends, scalebars, annotation,
and other features. The Print Layout tool is
available through an icon in the main window
(see right), either by selecting the Projectà New
Print Layout option from the main menu, or by
pressing the Control and P keys simultaneously. See the video QGIS3x Basic Layout on the
Mapeez YouTube channel.

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

The typical sequence follows these steps:

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

Setting Relative Paths While Saving

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:

Add the roads.shp layer from the Lab 1 directory.

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.

Close the data layer information window.

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.

On Windows 10 it looks like right:

Click on Project near the upper left of your


screen/window then click on Properties in
the subsequent drop-down menu. This will
open a new menu, click on the General option,
and then set Save paths to Relative (figure at
right).

Relative paths only save as much of the path


as needed to get from your data layer to your
project.

If you save your project and data in the same


directory, and make your paths relative, then
you should avoid most of the “lost data”
problems.

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) Click on the Symbology 2


option in the left-hand
panel to activate
2) Select the color style by 1
changing the Single
3
Symbol option to
Categorized.
3) For Value, select the
WETLAND_TY column.
4) Click the Classify button to
list out the categories for
the active column.
5) click the Apply button to
color the layer per your
settings. 4
6) click the OK button to 5 6
close the symbology
properties if you’re satisfied
with the result.

1.Sep.24 11
QGIS 3.x Exercises Introduction to QGIS

If you don’t like the colors for a specific category,


you can double click on the patch in the color ramp
to set the individual color via the Symbol Selector.
For example, double clicking on the patch for the “U”
category symbol in the figure above would display a
symbol selector menu something like the figure
right.

Double clicking on the Color panel near the


middle of the menu (arrow) displays a Select Color
palette, where you can select a different color. After
specifying the color, click OK in the Select Color
selector menuà OK in the Symbol Selector
menuà Apply on the Layer Properties Symbology
menu to apply the change on your map.

1.Sep.24 12
QGIS 3.x Exercises Introduction to QGIS

You may also hide categories from the


display by unchecking their symbols in the
Layer Properties Symbology window
(figure left).

You may delete categories entirely by clicking


on the value (e.g., PSS in the figure), and
then clicking on the Delete button (red minus)
at the bottom of the patch window.

You can select multiple items. Holding the shift


key and clicking on a first, then a last value in
a list will select a range. Control-click (PC)
and CMD-click (Mac) will allow you to select
multiple, distinct categories. You can batch
delete selected items by clicking the delete
button. These will then not be displayed in
your data pane.

You can also change multiple categories to the


same color, by selecting a groupà right click over
the selected groupà select Change Color… from
the dropdown menu.

This should open a color palette window. After


specifying the color and clicking OK, you should
get the same color for all the selected categories.

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.

Export the map to a PDF, and save/close this project.

1.Sep.24 14
QGIS 3.x Exercises Introduction to QGIS

Part 2: Practice and More Tools

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

Setting the Layer Order

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.

You should see a measurement window. Position the


cursor over the gravel pit, then click.

Note that as you move the cursor to another location,


the number that starts at 0.000 in the window (right)
will rise. This reports the distance for that segment,
and the total in the bottom window will also increment
upward.

Move the cursor to the lookout tower and click.


Another number appears below the first, it should start
at zero, showing a new segment is started.

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

Multiple maps on One Page

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:

1. Loading all the data we wish to display in to a QGIS project


2. Setting the symbology for the first map we wish to display
3. Opening a new map layout and setting the window, scale bar, and any other map elements
you wish
4. Locking the display elements for the map in the Item Properties (remember, tabs in the
rightmost pane of the print layout), under layers, lock layers, and lock styles for layers check
boxes.
5. Going back to the QGIS Data/Map window and changing the zoom, pan, and symbology to
that of the second map you wish to display
6. Returning to the existing map layout, and adding a new map. This new map can have the
same data as the first map for an inset, or you can display entirely different data, simply
turning a layer on or off in the table of contents.

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

Watch the video on multi-panel


maps if you have difficulties.
Make sure the larger map is
active when you add a scale
bar.

Note that the inset and main


map are usually at different
scales, as here, they will have
different scales scale bars. You
only need to add a scale bar here
for the larger map, and it is best to
set the final zoom for that panel
and then add the scale bar for the
panel before you lock it. An
added scale bar always applies to
the currently active map.

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.

Once you find the topology checker, click on it to open


the Topology Checker Panel, which will appear on
the right side of the screen. To create rules, click on
the Configure button (the wrench, arrow in figure
right).

This should open a rule-creation


menu, as shown right.

You create rules through


dropdowns in the three buttons
along the top, and then click on the
Add Rule button to build your list.
If you make a mistake or wish to
change a rule, you can use the
Delete Rule button and then add
new rules to the list.

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.

You then check for errors by clicking on the Validate


button, which checks for errors in the entire data set
(arrow at right).

An error should show up in the main topology checker


pane, similar to that shown at the right. Clicking on the
error will highlight the “offending” polygon. In this case,
both polygons overlap each other, so the choice it
highlights is rather arbitrary.

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.

Add the rivers.shp file to your canvas. Open a new


Topology Checker Panel and add a rule for the
rivers data layers, specifying that it must not have
dangles.

1.Sep.24 23
QGIS 3.x Exercises Introduction to QGIS

Save and then Validate the rule for the entire extent.

You should see a list of errors appear in the Topology


checker. Red dots appear in the data pane, if you zoom
to full extent you should see something like the figure to
the right.

Each dot represents a dangle. Some of these dangles


are acceptable, e.g., where a river starts, but there
should be no dangles where two rivers join.

How many of gap errors where rivers join can you find?

Typically, we would edit to fix the topological errors,


something described in a later exercise.

That’s all for this exercise, we’ll be using most of these


data display and map symbolization skills in the rest of
the exercises in this series.

1.Sep.24 24

You might also like