Welcome to Nate’s QGIS Tutorial!¶
Please check out the installation and sample data sections for information on getting QGIS installed and a copy of the sample data I’ll be using in the workshop.
Thank you,
Nate
Contents:
Installation¶
QGIS can be run on windows, mac, linux, and android. The instructions below are focused on windows users.
Download the QGIS installer from: http://www.qgis.org/en/site/forusers/download.html
Note: for windows users, there’s a basic installer and an advanced one. The basic installer will be enough for most of you, but advanced GIS users may want to use the advanced installer because it will be easier to install additional features (like Esri File Geodatabase compatibility and development tools).
Basic Installation¶
The basic installation should be fairly straight forward and involves a ~290MB download (for the 64bit version) or a ~340MB download (for the 32bit version). Unless you have a 32bit operating system (which is increasingly uncommon now), I advise that you get the 64bit version.
Advanced Installation¶
- Make sure you’ve downloaded the OSGeo4W version of the installer. This is a relatively small download because it’ll download the components that are needed for your selected options.
- Select the Express Desktop Install

- Select the Download Site: http://download.osgeo.org

- Choose the applications to install. I suggest leaving the default.

- Accept the list of unmet dependencies and allow the installter to install them.

- Accept any of the “Agreements of Restrictive Package” (there may be more than one)

- The needed components will be downloaded and installed.

- Confirm that installation has completed successfully

This will give you an installation of QGIS that is effectively identical to the Basic Installation.
You’ll note that you also have a new shortcut in your start menu for the “OSGeo4W Setup”. If you open this you’ll be able to add or remove individual features. There will also be shortcuts for uDIG (another light weight open source GIS desktop application)
Adding File Geodatabase Access¶
- Open the OSGeo4w Setup application and select Advanced Install.

- Select “install from Internet”

- Accept the default root install directory, unless you changed it as part of an earlier installation.

- Accept the default local package directory, internet connection settings, and download site.



- You’ll then see the Select Packages dialog.

- Locate the feature you wish to install. In this example we’ll find the Esri geodatabase libraries. They’re in the “Libs” section. Expand the “Libs” section by clicking on the + sign next to it.

- Scroll down until you find “gdal-filegdb” under the Package column.

- Click on the “Skip” under the “New” column and it will change to show the version to be installed. Then click “Next” at the bottom of the screen.

- Your feature will be downloaded and installed.
Basics¶
Much of QGIS should be familiar to those of you with existing GIS experience. Learning to work with QGIS will be largely a matter of learning where tools are located and possibly alternate names for them. The concepts are all the same, and much of the functionality is as well.
There are some places where QGIS is better, or more flexible than ArcGIS, some places where you can accomplish tasks in QGIS freely that require higher level licenses in ArcGIS, and others where ArcGIS is the better tool (Cartography and map production).
Anatomy of QGIS¶

The anatomy of QGIS is very similar to ArcMap
Many of the toolbars and windows are dockable so they may move around depending on how you set things up. Here’s a view of my version.
The Main Menu with access to settings, plugins, geoprocessing and raster processing menus.

The map.

Tools for adding data to the map. Vector data (shapefiles, PostGIS, Spatial Lite), Raster Data (GeoTIFF, img,...), WMS, WFS, CSV, and a very wide variety of other data formats that can be translated by the OGR toolkit into a compatible format.

A browser that is very similar to the catalog component of ArcGIS.

A Table of contents that can display layers by order or by source.

Project Management. A project in QGIS is roughly analogous to a map document (.mxd) in ArcGIS.

Map navigation. Zoom, pan, and scaling tools.

Selection and calculation tools:

Labeling tools

Editing tools

Coordinate and projection information.

Layers¶
Once you’ve added a layer to the table of contents you can double click on it to get into it’s properties.

The tabs along the side allow access to different aspcts of the layer. These are very similar in function to ArcGIS. These include:
- General: Layer name, coorinate reference system, visibility and feature subsets
- Style: Feature symbology
- Labels: Feature labeling
- Fields: The display and types of fields
- Rendering: Simplification of features for display purposes
- Display: Setting popup and default identify behavior
- Actions: User defined layer actions, such as showing an image when a feature is clicked on.
- Joins: Add or remove table joins
- Diagrams: Create charts or diagrams based on the the layer’s attributes.
- Metadata: Edit metadata for the layer.
Probably the most notable difference is in how symbology is specified in QGIS.

There are seven types of symbology for vector layers:
- Single symbol, Categorized, and Graduated. These first three behave much as you’d expect.
- Rule-based allows you to specify individual rules for displaying features.
- Point displacement is for specifying the displacement of points based on feature attributes.
- Inverted Polygons, styles everything outside of the features. This is useful for drop shadows or area boundaries.
- The Heatmap renderer generates dynamic heatmaps for point or multipoint layers.
Setting the symbols takes some getting used to. You’ll need to specify the fill and the boundary. “No Pen” and “No Brush” are use to indicate that there is either no fill or no outline on features.

Building color ramps takes an extra step that will be described elsewhere.
Projections¶
Projections take a bit of getting used to in QGIS if you’re used to ArcGIS. Most projections are dealt with through specifying their EPSG codes.
QGIS does have a very useful set of tools for searching for and specifying projections and unlike ArcGIS we can turn reprojection on the fly on and off easily.
Project on-the-fly¶

Reproject on the fly is not active by default in QGIS. You need to specify a projection for your project and then turn it on in order to use it. I like this feature. It is useful for figuring out projections that are either not specified (missing .prj), or incorrectly specified.
You can access the project’s spatial reference settings either through the main menu, or the button at the bottom right of the screen that shows the EPSG code.

Layer Projections¶
Layers give you a similar dialogue for identifying the projection. This can be accessed through the “General” tab on the layer properties. The spatial reference selector remembers your commonly used projections.

Reprojecting Data¶
To reproject vector layers that are in your table of contents, simply right click on the layer name, select “Save As” and in the save as dialogue, specify the projection to use through the spatial reference selection dialog.

Rasters should be reprojected using the GDAL Warp tools under the Raster menu to specify resampling methods and cell sizes.
EPSG Codes¶
A very useful site: http://spatialreference.org/
Commonly used EPSG codes: (at least commonly used by me)
- 3857: Web Mercator
- 4326: WGS84 (Lat-Long)
- 4269: NAD83 (Lat-Long)
- 3310: California Albers NAD83
- 3309: California Albers NAD27
- 2225: NAD83, California State Plane Zone 1(US Feet)
- 2226: NAD83, California State Plane Zone 2(US Feet)
- 2227: NAD83, California State Plane Zone 3(US Feet)
- 2228: NAD83, California State Plane Zone 4(US Feet)
- 2229: NAD83, California State Plane Zone 5(US Feet)
- 2230: NAD83, California State Plane Zone 6(US Feet)
Tables¶
Tables work very similarly to ArcGIS
The data used below is available at: Link
Adding the Data¶
Add the parcels layer to your QGIS project using the Add Vector Layer button.

Use the brows button to find the shapefile.

Also add the land use lookup table (lu_lut.dbf), you can do this through the add vector layers button if you then select “All Files(*).(.)” in the bottom right.

Inspect the Data¶
Right click on both the parcels shapefile and the look up table and for each select “Open Attribute Table”. Look at what is in them. The parcel dataset is just a small portion of a county, and I’ve reduced the number of fields to keep it small and manageable. There’s an APN field, the land and structural value fields, and a land use code.

The lookup table has a pair of land use code fields that can link to the parcel dataset (we’re only going to use one), and another set of land use codes that crosswalks the assessor’s land use codes into a standardized land use code that could be used across county borders.

Joining Tables¶
Double click on the parcel layer to open the layer’s properties, and then click on the “Joins” tab on the left side.

Now click on the little green plus sign near the bottom. Fill out the menu:
- Join Layer: lu_lut
- Join Field: PARUSECODE
- Target Field: LANDUSE1

Now use “Open Attribute Table” on the parcels layer again. If you scroll to the right you’ll see the additional fields.
Symbolize¶

Let’s symbolize the parcels layer based on one of the fields we just joined in.
Double click on it again to open the properties and go to the “Style” tab.
Then, select the Categorized style type at the top.
Set the Column to “lu_lut_ANDNAME”
And finally click the “Classify” button below the open window. You’ll now have a list of all of the entries in the lu_lut_ANDCODE field and will have random colors assigned to them.

If you now click “OK” you’ll have a (probably) garishly colored map of land uses.
Those colors can be cleaned up through the same user interface by clicking the colors and changing them. If you edited them to get a color scheme that you liked, you could save it using the “Style” button at the very bottom of the screen which will open to reveal a “Save Style” option.
Editing¶
Editing in QGIS uses an edit session much like ArcGIS does. Both attributes and geometries can be edited.
Calculating an Attribute¶
Add the parcel data to the project if it isn’t already there. If you’re continuing on from the last example, remove any joins using the layer properties to keep things simple.
Open the parcels attribute table.
Click on the little pencil at the top left of the attribute table to start an edit session.

Click on the Abacus icon at the far right of the top toolbar to open the calculate field dialog box.

And then fill out the form. We can have it perform the calculation into a new field that will be created to hold the result. An example is shown below.

And click OK to execute the operation.
Then click on the “Save Edits” icon just to the left of the Edit toggle to save the changes and then turn off editing using the pencil again.
Finally, let’s set up some symbology based on the field we just calculated.
We’ll use a graduated symbol on the netvalue field we just created. For the moment, just accept the defaults, and click the “Classify” button.

Then click “OK” to view the results on the map.

That’s really not so interesting to view, so let’s fix it a bit. Go back into the Style editor (Layer Properties).
And pick the “Natural Breaks” mode on the right side to use the “Jenks” method for splitting the data into the number of classes selected (default = 5).

And click OK to view the results.

Geometry Editing¶
Editing geometries should be similar to what you’re accustomed to. The feature templates that are available in ArcGIS aren’t present in QGIS, but the basic editing tools are available, and highly functional.
Snapping controls are available through the Settings menu.
Splitting a Feature¶
First toggle editing on using the pencil icon on the editing toolbar. You’ll see the vertexes highlighted.

Then select the parcel that you wish to split using the standard selection tools.

Turn on the Advanced Digitizing toolbar by right clicking in an open space near the menu and turning it’s check box on.
Then select the split feature tool. And click to create the line that splits the polygon the way you want to.

And right click to finish the split.

Adding a new feature¶
Navigate to a location where you can add the a new polygon.
Select the “Add Feature” tool from the “Digitizing” toolbar. Then you can draw in the polygon you want by clicking on each vertex.

Right click to finish the feature and fill in any attributes you need to.

Finishing the Edits¶
Save the edits and turn off editing to save your edits fully.
Geoprocessing¶
The concepts for geoprocessing are very similar to those you’ve learned in ArcGIS. All of the common methods are available:
- Intersect
- Union
- Buffer
- Clip
- Difference
- Dissolve
These are all located under the Vector menu.
Create Polygon Centroids¶
Add the parcels layer to your project.
Under Vector select Geometry Tools and then Polygon Centroids.
The image below doesn’t show the last portion of menu tree.

Select the layer to create centroids from, and specify the output data set name.


Buffer¶
Buffering the centroids by 1000 feet (because the parcel layer is in State Plane Zone 3 (US Feet))
Find the Buffer tool under Vector, Geoprocessing Tools

The “Segments to approximate” setting allows you to “tune” the detail that corners on the buffer have. The higher the number the more and shorter segments are created.


Intersect¶
(note I’m going to skip doing this one in the live demo)
Intersecting the centroids with the buffers will start to let us know how many parcels have centroids within 1000 feet of the center of each parcel. This would let us calculate a parcel density, and is a technique that I use frequently when doing summaries of land use.
The Intersect tool is in Vector, Geoprocessing Tools

This process takes a bit longer to run because it’s an exponential calculation.


Voronoi Polygons¶
Voronoi Polygons require an ArcGIS advanced license to create. It can be done within QGIS.
The Voronoi Polygons tool is in Vector


SpatialLite and PostGIS¶
One of the really powerful features of QGIS is the ability to link directly to SpatialLite and PostGIS databases. This allows the use of complex spatial queries that may take many steps to complete through the linking of individual Geoprocessing steps.
Rasters¶
All of these examples will start from the dem_4269.Tif raster in the demo dataset.
Start by adding dem_4269.tif to an empty project. Bonus points if you can tell me where it is... Elevation is in meters.
Terrain Processing¶
Add the Terrain Analysis Plugin¶
Go to Plugins, Manage and install plugins
Click on the Installed tab on the left. and look for the “Raster Terrain Analysis Plugin”, and turn it on with the check box to it’s left.

Reprojecting a Raster¶
Reproject from the current geographic projection (NAD83) (EPSG: 4269) into something a little more friendly for doing terrain analysis (without using Z-factors).
Under the Raster menu, go to Projections and select Warp
I’m going to reproject it to California Albers NAD83 (EPSG: 3310) using the cubic convolution resampling method.

After the reprojection, I’m going to remove the 4269 dem, and set the project’s spatial reference to 3310. Set the spatial reference using the button at the lower right corner of QGIS.
Styling¶
By default many of the best color ramps for displaying terrain aren’t turned on.
To turn them on, we’ll use the Style Manager.
Open the Style Manager by going to the Settings manu, and selecting Style Manager

Then select the “Color Ramp” tab.

Click on the little green + sign to add a new style and select cpt-city

Then select the Topography section.
Scroll down to pick the wiki-schwartzwald-cont color ramp.

Then click OK and accept the default name for the gradient and close the style manager.
Last, let’s apply it to the dem.
Turn off or reorder the layers so that the dem is visible. I suggest leaving the hillshade on top of the dem.

Double click on the dem layer and go to the layer’s Style properties page.

Set the Render type to Singleband pseudocolor, and under “Generate new color map” pick the wiki-schwartzwald-cont. Then click the Classify button.

Now, Click OK

One last step. Let’s open the properties for the hillshade layer and go to the Transparancy settings. Set the transparancy to about 70%

And click OK again. Then turn the layer on.

Raster Math¶
Reclassifying Datasets¶
First, we need to create some reclassified rasters from our existing DEM and Slope layers.
I’ve prepared some reclass text files to help us with this. Download these and put them in the same folder as your sample data.
Working through the Slope as an example. The DEM will work exactly the same way.
Open the Processing menu, and select Toolbox
Then at the bottom of the new window that opens select the Simple interface and switch it to Advanced interface.

Open the GRASS commands, and the Raster (r.*) sections and navigate down to r.reclass


Double click on the tool to open the dialogue. Fill out the settings, making sure to select the correct input layer, reclass file, and set the output file.

After clicking OK, the process will run and it will be added to the table of contents. Repeat the process for the DEM using the DEM’s reclass file.
For convenience, I’ve renamed the layers to the file name from the default that names that they have when added to the table of contents.
Raster Calculator¶
Map Algebra is then very simple.
Open the Raster menu and select Raster Calculator

And build your map algebra function and set the output file.

Then change the style on the layer to reflect the resulting classes. I used the Singleband pseudocolor renderer and added the values individually.
- 11: Low Slope, Low Elevation
- 12: Low Slope, High Elevation
- 21: High Slope, Low Elevation
- 22: High Slope, High Elevation

Resources¶
User Manuals¶
The official documentation http://www.qgis.org/en/docs/
Advanced Materials¶
QGIS API documentation http://www.qgis.org/api/
PyQGIS Cookbook for python programming in QGIS http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/
QGIS Plugin Development http://anitagraser.com/tag/plugin-development/
Sample Data¶
Sample Data
(10.5MB)