Lab 1: Introduction to QGIS
This term you will be using QGIS to learn how a Geographic Information System (or more commonly referred to as a GIS) operates. QGIS is free and open source software package (FOSS) that is developed using open standards. We will be talking more about Open Source and Open Standards in this course, but for now we will just happily use the software.
With the software being Open Source, you can download QGIS on your personal computer quite easily (even for those non-Open Source Operating systems). As this may be the first course for you in GIS, QGIS is a great option for use (as it is quite easy to work with).
We also use the most popular desktop GIS software in the GIS Lab – ArcGIS (including ArcMap) by ESRI. ArcGIS may be considered the defacto standard for GIS software globaly, but the methods you learn in this course using QGIS can be easily migrated for use with ESRI products.
This introductory lab is meant to walk you through of:
- Working with GIS project files
- Accessing lab data
- Downloading Open Data
- Starting new projects, loading existing projects, saving projects
- The basic interface features of QGIS
- Working/understanding Spatialdata layers: point, line, polygon, and attribute tables
- Styling your spatial data
- Composing a map
Locating data for lab:
Data stored in the GIS Lab
The first data set we are going to use is kept in the labs folder on our GIS File server. This is where you will find all the data used for labs taught in the GIS Lab as well as other data used for projects. There are other places on the server for data, but this where we will be starting.
Understanding where data is and where how to manage your own spatial data.
Before we start QGIS, lets ensure we understand how were are actually managing the data we will be using for Geog 204. Using the file browser, create a folder in your home folder (or workspace) called geog204 (many of you may have already done so in the tutorial). You will find in easier to create directories with no spaces in the name (a good practice for outside the GIS Lab as well). Inside the geog204 folder create another folder called lab1. This is where we will be putting files into for our lab this week. Below you can see a sketch made using a keyboard that shows the tree (upside down) perspective of how files and folders managed. You can see where Scott’s files are located relative to the labs for instance. It is always a good idea to find out where file are stored on a computer (not just accepting the default locations such as “Documents” or “Photos”.
/ \ / \
geog204 enpl303 stuff geog204
/ \ / \
lab1 lab2 lab1 lab2
Getting data from the lab folder
Spatial data comes in a variety of types and formats. I comes in all sizes and with out proper management – looking for spatial data can become a real nightmare. Using the file browser on the desktop of the computer navigate to /home/labs/geog204/lab1/first_project. You can ask your TA (Aita) of Scott how to set your file browser to display your location on the file system to show the path to the files. Once there you notice a whole bunch of files that are used in QGIS.
If you set your browser to present the contents of the folder in a list (or details) view, you can see that there are files with the same name but different extensions. You can look up what the different file extensions are used for (what files are associated with specific software or uses) by going to fileinfo.com. This does not really work for the files we have in the folder though. These files represent layers that will be added to QGIS in the form of a “shapefile”. We will discuss this in lecture, but for your first mark in the coarse – answer the following questions about shape files.
Question 1: (one mark)
How many files represent the layers we are going to use in the lab today (i.e how many files for “pg_rivers”? These files represent “shapefiles, and unlike software such as word – more than one file is required for a shapefile to be used in GIS software. Determine which of these files are mandatory for use in software (HINT: use Wikipedia).
You may have also noticed there is a file with the extension .qgs. This is a QGIS project extension. We will be using it in the next section.
Opening QGIS and getting started:
To open QGIS you click on the ‘Menu’ button on your screen (it will probably default to the bottom left hand corner as you can see circled in red). Now you can either type qgis or hover over ‘Education’ in the task panel and you should be able to see QGIS Desktop program – open it. You may see a Tips section pop up, feel free to read through those at your leisure as they are often quite helpful.
In order to give you the opportunity to more easily explore QGIS we have provided a project file. As mentioned above, project files end with .qgs and contain the information necessary in saving and reloading your work. You can find your project file options under the Project tab. Go ahead and open up the geog204_lab1.qgs file you navigated to above.
Project –> Open –> navigate to geog204_lab1 –> Open.
You should have some Prince George relevant data on your screen! You may also notice that your screen is slightly different than the one shown here (click on the image for a larger view). This is because many of the windows, and shortcuts to tools can be added and removed from the main screen of QGIS. Don’t worry if a feature you normally use disappears or is moved out of place. You can customize QGIS to make your life easier.
Panels and toolboxes:
You can add and remove panels by right clicking within the empty gray space along the top section of the QGIS window. Let’s just start with at least the Browser Panel and the Layers Panel enabled. They should be on by default, but you can add others if you wish. Other useful panels are:
- Browser Panel
- Layers Panel
- Log Messages Panel
In addition to adding and removing panels you can also move them around the screen, providing the opportunity to customize the user interface to reflect the features you want quick and easy access to.
As part of the package you are creating to hand in for this lab, take a screenshot of your QGIS window that includes: the panels that are enabled and how you have arranged your panels (there are no grades associated with how you arrange panels). This screenshot will show that you are able to add and remove panels. Below is an exmple of customizing your qgis session:
You can grab a screenshot by using the screenshot application from the Linux Menu bar. Aita or Scott can show you how to perform this action.
Panning and Zooming:
Let’s try to provide a screenshot of a park area within PrinceGeorge. This screenshot must contain the entire area of the park. As you will find out with GIS there are often many ways you can accomplish tasks such as this one.
Some of the tools you will/could make use of to accomplish this are:
- The Pan tool (the white hand icon that is usually the default tool when you turn QGIS on) allows you to move around the map content screen (or often called the map canvas).
- Icons that have magnifying glasses are usually associated with a zoom feature. There are many different zoom features, and ways to access them. The scroll button on your mouse will zoom in and out the same as the zoom and zoom – tool. Take some time to try out what these different zoom features do.
Inside the ‘Layers Panel’ (often called the Table of Contents), you should see a list of layers that was loaded when the project file was opened. Do you notice the layers stack up for maximum visibility. Area layers (polygon layers) are at the bottom of the list, with line layers on top of them and points finishing the map off. Ensure the pg_trees annd pg_parks layers are turned on by clicking on the empty box beside the layers in the layer panel. You can change the order of layers by dragging them up and down in the Layers Panel list. The way these layers are displayed is based on the order they appear in the Layers Panel. This means a layer that is turned on and is on the top of the list is drawn on top of the enabled layers that fall below it, in a stacking effect.
By right clicking on a layer within the Layers Panel a list of options appears. Open the Properties for a layer. Properties are useful for but not limited to the following: general information about the layer, labels, metadata, and styling.
Under the General tab of Properties you have easy access to the name of the layer, the name QGIS is displaying for this layer (it will be different than the name of the layer if you have renamed a layer in QGIS), the location of the layer on your hard drive, and the Coordinate reference system of the layer.
The Metadata tab is essentially the citation information of the layer. You will likely notice that this section is often left blank, though ideally it would always be filled out correctly.
The Style tab allows you to change the appearance of layers on the map. You will need to use this for the final output of this lab, a map.
This is by no means a complete overview of all the tabs or even what individual tabs can do. Instead this is a quick overview of some of the basics you need for this lab.
Spatial layers are more than just lines drawn on the screen, they also contain information for each feature in the layer (hence Information (I) in GIS). For example the tress layer has the name of the type of the trees for each point (tree) on the map canvas. You can open the Attribute Table of a layer by right clicking on it within the Layers Panel. You will notice that the attributes for the features in the layer are presented in the same manner as a spreadsheet (such as those used in Excel)
Highlight a layer in the layer panel (perhaps the parks layer) by clicking on it once – the layer should now have a blue band over it. This makes it an “active layer”. We can then select features in this layer. Open the attribute table for this layer as well.
You can select features in the map by using the “Select Features” tool hover your mouse over the tool icons until you find the “select features by single click or area” tool
and activate it by clicking on it. Once the tool is active select a feature in the layer. Check the attribute table once a feature is selected – you will notice that a row in the table is also selected.
Do the reverse by selecting a row in the table and use the table tools to zoom to the feature selected.
What is the name of the Park that one of the three Siberian Elm trees is in. Once you have selected the tree within the park, take a screen shot of the selected tree and a portion of the park.
Creating a map using Print Composer:
This course is not designed to spend a significant amount of time on teaching the art of making good maps, as this is covered in Geog 205 – Cartography and Geomatics. However, it is important to at least mention some of the basic components of a map that you will be expected to include in all the maps you hand in for this course. You will generally need to have: a title for your map, your name on the map, a legend, a north arrow, a scalebar, and when appropriate a description.
Print Composer is the tool you use to create a map, while the window you have been using to explore the data up until this point is more of a data view window. To open up Print Composer find it under the Project menu, and give your map a file name. Most of the tools you will need to use to make your map are found under the Layout tab.
To add data you have prepared in your projects data view window, use the Add Map tool. You are now able to create an area (drag out) the size you want to be filled with your map content. You will want to consider the space needed for the title, legend, north arrow, scalebar, your name, and any other pertinent information. Fortunately you can resize and move this at any point in the map making process.
After you have added data, you may notice that the data view and map view you just added don’t look exactly the same. You will probably have to pan around and change the resolution to work with the in Print Compose, which can be done using the Move Content tool. The actual Zoom buttons within Print Composer are a bit misleading, instead of zooming the map panel content it actually zooms the entire Print Composer window. Using the scroll wheel on the mouse when Move Content is enabled is an easy way to zoom in or out.
Title: To add a title you will create a Label, which will appear in the Item list. In the Item Properties tab of this label you can add the title text. If you think the font is not the ideal size, this can be changed in the Font menu. You can add your name and a brief description to the map using this same procedure.
North Arrow: Use the Add Image tool and pick a size and location for the north arrow. Similar to creating a title use the Item Properties and expand the Search Directories options, where you will see previews of the pre-loaded images provided in QGIS. Pick a north arrow you like, and if the north arrow doesn’t appear you may have to manually adjust the styling options for it. To do this open the SVG Paramet4ers found under Search Directories. It is also possible to create your own images or find other images and use them as well (but you are by no means required to!).
Scalebar: By now you are familiar with the general process of adding additional map elements, so add a scalebar. It is important to make sure that the units being displayed on the scalebar are appropriate to the context of the map you are creating. For instance it would not be appropriate to have a map with a scalebar measured in miles when the map is for Prince George (Canada).
Locking layers in place: At this point you have enough separate elements in your map that you may have ran into some frustrating relating to having something positioned and sized perfectly only to accidentally move or resize it. Any of the items you’ve added to the map can be locked in place (which also locks they styling). This option can be found in the Item Properties, and can be disabled if you need to make any changes later.
Legends: If your legend has auto-populated all the layers from the data view window, and you want to change this – disable the Auto Update feature in the legends Item Properties menu. When Auto Update is disabled you can reorder or remove layers from the legend. You only want the legend to show the layers you actually have in the final version of your map, so take a moment to verify everything is in order. You can also change the background colour and many other design features in the Legend item features.
Question 3: Export your map
Create an export of your map – it does not have to be fancy looking – by using the export function in the composer. You can export the map in a few formats, but for the sake of bringing the map into software such as word – we will export the the map as an image. Composer -> Export as Image –> choose the file (ensure it is a PNG or JPG).
Downloading and adding data to your project
We downloaded the data layers for this project from Open Data Prince George (the city of Prince George data sharing site) at http://data-cityofpg.opendata.arcgis.com/
Visit the site and perform the following steps
- download at least one shape file to your geog204/lab1 folder.
- the file will come down as a compressed zip file.
- locate the file in your folder and decompress the contents of the file (right click –> Open with Archive Manager –> extract it to the folder).
- open the data layer into QGIS (Layer –> Add Layer –> Add Vector Layer –> navigate to the folder and select your layer
- style the layer accordingly
Question 4: (2 marks – including your write up
Follow the steps above to add the Incorporation Boundary layer to your project. Once you have it loaded perform the following steps to provide another screenshot of your results:
- Style this layer by using the “catagorized” method using the attribute column for year of incorporation
- Place the existing layers in an order for proper viewing
- Colour the one feature in your new layer Red that matches the criteria described next
- Take a screen shot and include it in your write up.
There is actually one more Siberian Elm in Prince George. It is actually in the backyard of Scott’s families old house. This house is located in the Millar Addition of Prince George. Read the Wikipedia article on the Millar Addition and determine which year this area (part of a larger incorporation boundary feature) was incorporated. This is the feature to colour red.
Do any of the the Siberian Elm trees in the pg_tree layer fall within the Millar Addition?
After your screenshots and exports are saved and you have begun to write up your lab, save this project to your lab1 folder (maybe call it something simple like – lab1). You then can close QGIS and logout.