A very short introduction to QGIS

Yesterday I posted a Google Maps lab assignment that I created for UBC’s Advanced Cartography course earlier this year. For that class I also created a short QuantumGIS (aka QGIS) tutorial to expose students to an open source GIS and the possibility of using OpenStreetMap data to make basic maps. Here is that tutorial, which I hope some of you will find useful.

Geographical Biogeosciences 472
Advanced Cartography
QuantumGIS tutorial

In this tutorial you will learn how to use open source GIS software and free data sources. Once you have graduated, you may not have access to expensive software such as ArcGIS. In this exercise you will see that it is possible to make maps with free tools and data.

What is open source software?

Open source software means that the underlying computer code that makes up a program is published freely so that anyone can read and modify it. This means that anyone can find and fix any bugs in the software, which can make it more stable and less susceptible to bugs or computer viruses. Open source software is also almost always free of charge, which is an added benefit.

The downside to open source software has it has a reputation for lacking user-friendly interfaces, and for being challenging to learn. Open source software is also usually under constant development, meaning that some features may be lacking or incomplete. That said, some open source software is more user-friendly and stable than others.

There are several open source GIS programs to choose from, such as GRASS, uDig, gvSIG, OpenJUMP, and Cartographica. In this tutorial we will use QuantumGIS (usually called QGIS), which is one of the most powerful, stable, and user-friendly open source GIS programs. You can download it for free, and it runs on Windows, Mac, and Linux.

While QGIS doesn’t contain all of the tools you find in ArcGIS, it lets you do a most of the basic GIS and cartographic tasks you are likely to need. It also includes a range of advanced GIS functions in the GRASS module, and you can add plug-ins written in Python if you need added functionality.

What is open data?

Just like GIS software, a lot of GIS data you encounter is not free. This either means you have to pay to access the data, or it means that you can download the data for free but are legally restricted in terms of where and how you may use it. Some free data is available from government agencies, such as the city of Vancouver (data.vancouver.ca), the government of Canada (data.gc.ca) or the US Census (census.gov/geo/www/tiger). Increasingly, you can also find data that has been crowdsourced by volunteers around the world using a creative commons license. The most popular example of this type of data is called OpenStreetMap. In this tutorial we will be using OpenStreetMap as an alternative to government or corporate data sources.

Part 1: Getting Started with QGIS

Downloading QGIS

Download QGIS from http://www.qgis.org/.

For Windows, choose the “Standalone Installer”. This should be the only package you need to install.

For Mac OS X, you will be redirected to another website (KyngChaos.com) where you will have to install a few required packages (GDAL and GSL) before you install the QGIS package. Make sure you download and install each of the required packages (and the optional packages for GRASS and Python if you wish) before you install QGIS.




As with all open source software, some of the best help can be found on the mailing lists and online forums associated with the software. If you have consulted the online documentation and still can’t figure out a problem, don’t be shy about asking your question on the mailing lists. More experienced users are usually happy to help.

The QGIS mailing list:


After you’ve installed QGIS, try starting it up. You should get a blank window with a toolbar along the top. Now we have to add some data!

Part 2: Working with open source data

If you are trying to make a map, you probably already have some thematic data that you are trying to visualize. So, for the purposes of this lab, we will demonstrate a source of reference data that you can use to make basic maps, or as supporting data for a thematic map.

OpenStreetMap (often called “the Wikipedia of maps”) is a collaborative free map of the world created by combining volunteer efforts with other public domain data sources. Unlike Google Maps, the raw data behind OpenStreetMap can be downloaded for free and used in a GIS. OpenStreetMap data is provided using a Creative Commons license which does not forbid using it in commercial products, but it does require that any improvements to the data must be shared back with the OpenStreetMap community.

You should be cautious when using OpenStreetMap data to be sure that it has sufficient accuracy and detail for your purpose (in fact, you should be cautious when using any dataset, for the same reasons!). Because OpenStreetMap, like Wikipedia, has been created largely by volunteers, you have no guarantee that the data will be accurate or complete. In some places data may be missing, while in other places OpenStreetMap may have data that is more detailed, accurate, and up-to-date than other professional or government data sources. Unlike other data sources, however, if you find an error in OpenStreetMap data, you can fix it yourself! Editing OpenStreetMap is outside the scope of this tutorial, but you can find out lots more about how to get started editing by going to the OpenStreetMap website: http://openstreetmap.org.

Downloading OpenStreetMap data

There are several third-party web sites that provide OpenStreetMap data in a variety of convenient formats. In our case we want the data in the form of shapefiles. We will download these shapefiles from a site called CloudMade. Start here:


Navigate down to the level of detail you want to download. For example, you might arrive at the page for BC:


You will see a variety of different file formats to download. In this case we want to download the file that ends in “.shapefiles.zip”, such as british_columbia.shapefiles.zip

Download and unzip the file, using whatever unzip program you have on your particular operating system. After unzipping, you will now have a folder called “british_columbia.shapefiles”. Read the readme.txt file inside the folder for a description of the different shapefiles in the folder.

Loading a shapefile into QGIS

Now we will load one of the OpenStreetMap shapefiles into QGIS (although the same steps apply for any shapefile you may wish to add).

Click this button in the menu bar:

Add Vector Layer

Or, choose the menu option Layer > Add Vector Layer…

Add whichever OSM shapefiles you find interesting, but make sure that you also include the “highways” layer.

Changing the style of a layer

Once you have added a layer, you will want to change its style. Let’s try changing the style of the highways layer. In the “Layers” panel, double click the highways layer. Now you can view all of its properties in the Layer Properties window that opens. (Note, if you don’t have your Layers panel open, you can activate it under View > Panels > Layers). The contents of the Layer Properties window should be familiar to you if you have used ArcGIS, although the appearance will be different.

Make sure the “Style” page is selected within the Layer Properties window. In the upper left corner of the window you will see a drop-down selection box that is currently set on “Single Symbol”. This means QGIS will apply a single style to all the features in the highway layer. Experiment with changing the style of the layer, either by adjusting the Color or Width properties, or choosing from the saved styles.

Now, try changing from “Single Symbol” to “Categorized”. Here we can choose which column in our shapefile we want to use to apply styles. Select “TYPE” as the column, and then click the Classify button. You will see that every type of road has now been placed in its own class (you might remember this type of classification is called nominal or qualitative).

To perform a quantitative classification, switch from “Categorized” to “Graduated”. Here you can select any quantitative columns from the shapefile. In this case, “LANES” is the only column we can select. Again, press the Classify button to perform an equal interval classification with five classes. (Those options can be changed to whatever you like). If you render the map with this classification, you will see that most of the roads in OpenStreetMap are lacking information on the number of lanes, so they show up in the 0 class.

Changing the projection

Another task you might need to perform in a GIS is the projection or reprojection of your data. You can determine the current map projection by looking at the EPSG code in the bottom right corner of your map window:

Coordinate Reference System (Map Projection) Status

The EPSG system is a catalog of coordinate reference systems and map projections. In this case, EPSG:4326 tells us that our data is stored as unprojected lat/long coordinates using the WGS84 datum. We will need to project this data in order to display it properly.

To open the projection properties window, click the globe next to the EPSG number. At the top of the list of projections are the Geographic Coordinate Systems, that is, the unprojected reference systems. Scroll down until you see Projected Coordinate Systems. Expand this option, then expand the Albers Equal Area option below it. Select the projection called “NAD83 / BC Albers”. Finally, check “Enable ‘on the fly’ CRS transformation” in the upper left of the projection properties window. Enabling this option makes QGIS function like ArcGIS, where the map view has one map projection, while the data layers that are within the window may have multiple different projections stored in their shapefiles. The projection in the original files will not change, but they will be reprojected dynamically so they are in the correct projection in the map view. Now click Okay to close this window.

You might find that your data seems to have disappeared. That is because the view remains centred on a particular set of coordinates, but those coordinates are now looking into a map view that has been reprojected. We are now looking in a different place! To find our data again, click the “Zoom Full” or “Zoom to Layer” button.

Zoom Full

Zoom to Layer

Now you should see your data again, this time reprojected to a more appropriate shape.

Part 3: Exporting from QGIS

Finally, if you want to add finishing touches to your map in Illustrator (or an open source alternative like Inkscape) you will need to export your map. You will export either as a PDF or an SVG file (either of these should be readable by Illustrator, but if you have trouble with one file type, try using the other one). The process of exporting is very similar to the process of printing in QGIS. Unfortunately, printing from QGIS is not immediately obvious.

To export as PDF or SVG, we first must create something called a Print Composer. Think of this like the Layout view in ArcGIS. First, select File > New Print Composer… to open the Composer window.

In the Composer window, set the paper size as “ANSI A (Letter)”. Now click the Add New Map button along the top toolbar in the Composer window.

“Add New Map” button

With the Add New Map tool highlighted, drag a rectangle in the blank white area at the left. This will be the extent of your map on the page, so most likely you will want to fill most of the white area, leaving a small margin around all sides.

You will be able to move the map inside this frame by using the hand tool, but you can’t zoom in or out on the map. If you want the map to be zoomed in or out, you will have to do this in the main map window, not in the Composer. To change the zoom, you will have to select and delete this map frame, then use Add New Map again once you have changed the zoom in the main map window.

Click Close to save this Composer. Now, in File > Print Composers you will see the new print composer you created. Open this composer, and click either the PDF button or the SVG button in the toolbar to export your map.

The PDF or SVG export buttons

This entry was posted in Mapping, not_geowebchat. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>