QGIS - Introduction to the Basics
Time for completion: ~ 2 hours


QGIS 0.11.0 Metis - Quantum GIS (abbreviated to QGIS)

Quantum GIS Forum - QGIS Questions and Answers

DO NOT print this lab! (please) Get used to "maximizing your screen real estate", or use two screens at once (one computer for the GIS, one for a web browser with lab instructions).

This lab will introduce a simple free GIS, where to get free data, some terminology, and serve as an introduction to what I call "driving the box". Do not let yourself get frustrated - if you have a question ask, that is why I'm here!

Terms: path, field, attribute, Identify (query), raster, vector, .tif, .img, shapefile (.shp), .zip, DEM, DRG, open source. QGIS is "open source" software and, more importantly, it will run on operating systems other than Windows. What is open source? There are open source operating systems, i.e. Ubuntu (and other flavors of Linux), that are free, and there are software that are free, Mozilla, QGIS, etc. (See: SourceForge.net). These are also open, which essentially means that what makes these programs work (the source code) is open to people (programmers) who can improve it and modify it. As apposed to "closed source" software and operating systems that are not open. Windows OS / Office are proprietary, ArcGIS is proprietary, Illustrator / Photoshop are proprietary ... only companies that own the source code can modify it (i.e. Microsoft, ESRI, Adobe, etc.). You will hear more about Open Source later in the course.

1 Start QGIS

What you are looking at is a "GUI" (Graphical User Interface), thanks to Microsoft this interface is widely known and understood. Externally, what you see is different than Mac, internally, what you don't see, is very different than Mac. There are probably better ways to interact with a computer than the standard issue GUI, mouse and keyboard we are used to, but it will be a long time, maybe never, before that changes.

If you hover with the cursor over a button there will be text that will explain what it is. Most GUI software works like this. There are many ways to do the same thing, most GUI software share this charcteristic as well.

1.1 Turn on Plugins

Click on the Plugins pull down menu, and select Plugin Manager ( Plugins -> Plugin Manager), check on; Add Delimited Text Layer, Georeferencer, Graticule Creator, NorthArrow, and ScaleBar. Click OK. Buttons associated with these plugins will then be added to the GUI. Each of the buttons has a "fly out menu" if you click on the black arrows.

In the screenshot above, buttons (red box) have been added to a toolbar. The toolbar you can move / re-arrange. We will use some of the Plugin buttons you just activated later on.

1.2 Explore the Pulldown Menus

Another acronym related to the concept of "GUI" is WIMP (Windows Icons Menus Pulldowns), for most things based on this type of interface there are two, and sometimes three or maybe more, ways of doing exactly the same thing! Shortcuts are a great thing.

To save a QGIS .qgs project there are four ways to do it;

1) use the mouse to go up to File -> Save

2) push Alt key, notice that menu names will have underlined letters; to Save a project hold down Alt+ f, the File menu will expand, then push s.

3) Ctrl + s

4) click the button that looks like an ancient 3.5" floppy disk.

All of these methods do the same exact thing - they save your QGIS map layout (not the data that the map links to!) to a .qgs file. Don't save anything yet, just do Cancel. We will save something later on in the lab. For now we're just cruzing through the software.

Take a look at what is under the other QGIS pulldown menus, note that each item in the pulldown menu has an underlined letter. These are the Alt key shortcuts, if the underlined letters are not visible push Alt. This makes doing routine things quick, and has the added benefit of making you look smart if people are watching.

Note: Using Alt and Tab together will let you switch between open programs, this is a Windows thing and is helpful if you find yourself using multiple programs. The #1 most important shortcut to memorize is Ctrl z (undo), this is pretty much universal in GUI software.

Now go to Settings -> Project Properties. Notice that next to this menu item (in the pulldown) there is a P. Pushing P (not capital) will open the Project Properties dialog box, same as doing Settings -> Project Properties.

The Project Properties dialog box has two tabs. Both are important and we will come back to this later. For now I'm just guiding you through this process, showing you how to familiarize yourself with software. Notice that in the screenshot above I've rearranged my toolbars. Click OK (or Cancel) to close the dialog box.

Go to Settings -> Options and change the Appearance of the GUI to use a different Icon Theme. While you're in this Preferences dialog box look through the rest of the folder tabs, just to get an idea of what is where. I don't expect you to memorize this. Learning new software is a skill all by itself, this is the way I do it; first I look at what the buttons do and read the associated words, next I look through all the Pulldown Menus.\. Last I do the tutorial that came with the software (if there is one), but in this case this is your tutorial. For most commercial software commonly used within the GIS and related professions there are tutorials and other aids; Macromedia, which is now Adobe, (Flash, Dreamweaver, Freehand), Adobe (Photoshop, Illustrator, Acrobat), CorelDRAW / CorelPHOTOPAINT, AutoCAD, MicroStation, ESRI ArcGIS, etc. all have their own tutorials as well as other "self teaching" type books.

2 Windows Basics

Start Windows Explorer. There is a keyboard shortcut (the window key, next to the space bar on the keyboard, and e), or it can be started by going down to Start -> Programs -> Windows Explorer. Go to C:\WorkSpace\ using Windows Explorer. If you are not already familiar navigating through the file system tree, you will learn. Ask for help if you need it, if you haven't done this before it can take some getting used to.

Note: window key and m will minimize everything if you get buried in multiple windows. Also, this lab now uses Windows Vista so some things may be different than Windows XP interface.

2.1 Creating a Work Directory

Every computer has, or should have, a C:\WorkSpace\ directory (the words "folder" and "directory" are synonyms in computer lingo). INSTRUCTIONS: create a folder on C: called Workspace (Alt + f, w, Enter, or right click in the white area in Windows Explorer, then push w then Enter. In that folder create another folder called qgis_lab, Save your empty QGIS map layout to ( C:\Workspace\ ), call it myfirstmap (the file extension, .qgs, will be added automatically). Create another folder under qgis_lab called data.

Use C:\Workspace as your working directory (not My Documents!). Your computer will work most efficiently if you work with your data on the harddrive rather than on a Removable Disk, Working from a USB Thumbdrive (Removable Disk) is sometimes problematic for ArcGIS.

The "path" to this folder is now C:\WorkSpace\qgis_lab\

*** do not put spaces in file or folder names, use "-" or "_" in place_of-spaces. For now just take this as the 11th commandment, the reason will be explained later.

2.2 Windows Explorer

Windows Explorer by default makes little pictures (thumbnails) of things, but this is not useful unless you're looking at pictures.

Note: some computer labs are setup so that some of the more annoying Windows settings have been fixed. If they are great, if they are not go through the following steps to make the Windows Explorer interface more useful.

Note: Windows Vista will be different. We will have to figure out how to do this together.

Change the view properties of Windows Explorer to list file names, sizes, dates etc. go up to View -> Details, to make it show you the file extensions go up to Tools -> Folder Options. In the dialog that opens click on the View tab and 1) uncheck "Hide extensions for known file types", 2) uncheck "Hide protected ...", 3) Turn on "Show hidden files and folders", and 4) uncheck "Remember each folder's ...", then 5) click Apply. To make this permanent for all the Windows Explorer windows you open click 1 Reset All Folders and then 2 "Apply to All Folders" button at the top. Click OK to close the Folder Options dialog. Now you will see files listed with their associated extensions a ong with file sizes.

Turn on the Address Bar. In the same Folder Options window scroll up to the top until you can see the two boxes with "Display the full path", check both of these on (see screenshot below). Then click Apply, and then click the Apply to All Folders button at the top (and Yes if Windows barks at you). Then click OK and close the Folder Options dialog.

Go into the new qgis_lab folder, double-click on it or push Enter. With the Address Bar turned on, the top of Windows Explorer will show the path. If you turn on Folder View (View -> Explorer Bar -> Folders, or click the Folders button at the top) the left part of Windows Explorer will show the "tree view"(see screenshot below), note the little + next to WINDOWS and the - next to WorkSpace, the - means that the folder is expanded. There is no little + next to the folder you just made qgis_lab, why? (because there is no folder in it).

The folder-in-folder, path vs. tree, + / -, shortcut things are parts of learning to "drive the box". Everyone learns differently, and there are many ways to do the same thing. The more you use Windows the easier it will become, and the easier it will be for you to learn to work with GIS and GIS data.

3 Getting Data

Below I will explain how to find and download free GIS data from CaSIL. As you might imagine there are some twists and turns, and everything will not be crystal clear, but you will learn about most of these things in time. We are going through this exercise to get started, many of the things mentioned in this lab will be covered in greater detail later. For now, just follow along, ask questions when you want to, and get through the lab.

3.1 Urban Areas

Go to http://gis.ca.gov/ -> Data Collections -> Frequently Accessed Data -> Cultural Geography, get to the "Urbanized Areas from 2000 Census Block Data" - this is metadata! (what is metadata?) There are different formats; check out the different formats, i.e. XML classic style. I've downloaded the file, imported it, transformed the datum to NAD83 and converted it to shapefile(.shp), hu? -- Download cen00ua02_nad83catealealbers.zip, save the file in C:\WorkSpace\qgis_lab\data\, extract the contents into that data folder.

FYI: These data were only available as .e00 Arc Interchange Format, which is an exported ArcInfo Coverage, bla?, we will revisit this format and many others when we start using ArcGIS, and it was in the NAD27 datum too, we will also revisit this later.

Now look at the C:\WorkSpace\qgis_lab\data\ folder with Windows Explorer. Note the file size of the .zip, it is 4,482 KB, which is 4.5 MB (about "four megs" in geek speak)

Now check out the folder you extracted from the .zip file;

Note that in the screenshot above, which was made with Windows XP (will look different with Vista), there are seven files. Each file has a different extenstion (never mind the icons Windows uses to try to identify the files). These files collectively constitute the most common form of vector GIS data you will encounter, a shapefile. We will revist GIS data formats late. Also, it is important that you understand file sizes, this we will return to in later labs too. How many KB are there in a MB, how many MB in a GB? What is a MB? What is a GB?

3.2 Download Roads

CaSil = California Spatial Information Library. There are a HUGE number of data sources, some better than others. CaSIL has GIS data for pretty much any topic you can think of, but some of it can be hard to get to.

Google is a marvelous new paradigm, but necessitates that one knows associated strings of text. These text strings for GIS are often acronyms; DRG and DEM. I've googled CaSIL DRG and CaSIL DEM and found the pages linked below. What follows is an exercise in finding and getting data. What we want to get are 1) Roads vector data for CA (what is vector data?), and 2) 1990 Urban areas polygon data for CA. Then we will find 3) a DEM (raster Digital Elevation Model) of Santa Clarita (what is a raster?), and 4) a DRG (Digital Raster Graphics) for Santa Clarita (what is a DRG?)

go to: http://gis.ca.gov/, follow the links -> Data Collections -> Frequently Accessed Data, look under "Transportation Networks & Models". The next page will be metadata, what is this again? why do I care?, find the link next to the Online Linkage XML field. Download the local_roads, us_highways, state_highways shapefiles to C:\WorkSpace\qgis_lab\data\, note that these data are available as a shapefile (shapefile format), but the individual files that constitute the shapefile are not compressed into one archive (.zip) file we can download and then extract as we did before - we have to download each of the files named local_roads individually.

3.3 Download a Hillshade and DRG raster data for Santa Clarita

This is a two step process. First we need to find which DRG we want; the names of the file we need to download that cover Santa Clarita.

3.3.1 Download a Hillshade raster

Go here: http://gazetteer.casil.ucdavis.edu/casil/maps/hillshades/ and download the three files that begin with hil90m_color_v2 in the /scaled/ directory then, after the 90m file has completed, download the hil30m_v1 files from the /0030m_ned/tiff/ directory. Beware, this second file is large and will take a while.

3.3.2 Download the DRG Index Shapefile

go to: http://gis.ca.gov/, follow the links -> Data Collections -> California Digital Raster Graphics -> CaSIL DRG Directory, CalSpace - UC Davis, CA -> 7.5_minute_series_albers_nad83_trimmed, scroll down to the bottom and download the drg24.* files. All of these files collectively would be refered to as the "drg24 shapefile" even though it is actually multiple files it is still refered to as "a shapefile". We will disect all these files later on, for now just know that a shapefile = a whole bunch of files. When we discuss data formats I will go intro greater detail about shapefiles and various other popular geographic data formats.

3.4 Examine your Workspace folder structure

For C:\WorkSpace\ note the tree vs. path idea; the red box on the screenshot below shows qgis_lab as a tree with Workspace as the "root" level of the heirarchy.

Notice that the qgis_lab folder has a folder, and that folder has a folder ... folders within folders ... this is a core concept to understand. Think of the path C:\WorkSpace\qgis_lab\data\ like you see in the tree on the left, this is "directory structure" - If you have questions about this ask. Yes, I could just give you all the data in a nice-neat folder and that would make it much easier but that would not help you at all. By making things too easy it might actually give you a false impression of GIS, rarely is it easy and staying organized is much more than half battle.

3.5 Add data to QGIS, the Attribute Table

Use Add Vector Layer to add the state_highways and cen00ua02 data to your QGIS map layout. Shown below with a red rectangle is the path to the file you want to open, you need to navigate to this file using the folder tree.

Make the Roads layer draw on top of the Urban Areas layer. Turn off / disable the ScaleBar and North Arrow for now. Then right-click on the cen00ua02, choose Open Attribute Table. Scroll over to the UA_NAME field, click on the column heading block to sort that field alphabetically. Scroll down to Santa Clarita and select both rows, click-and-hold on one row, hold down Ctrl, click on the next row. Nex, click the "Zoom map to the selected rows (Ctrl F)" button. See screenshot below.

The Attribute Table is a critical defining component of what makes data "geographic data" - objects (polygons, lines, points) in maps are linked to a table of attributes. More on this later. Use the Identify Features tool to click on a Santa Clarita polygon and read it's attributes from the Attribute Table.

Note: In order to Identify a feature (polygon, line, point) you need to have the layer you want to Identify selected on the left side, to do this just click on it. The window that opens after you click on something with the Identify shows those "records" from the Attribute Table that are linked to the polygon you clicked.

Highlight the roads layer, the use the Identify tool to click on one of the roads. The attributes you see in both the roads and city shapefiles contain different things, you can find out what the attributes mean by reading the metadata. Close the Idetify Features dialog box. Right-click on the roads layer and select "Zoom to layer extent". Ya, I know, it's an ugly map but we'll worry about that later. What we really need to do is find those code for the DRG.

3.5.1 Find the DRG names, download from CaSil

Add the drg24 shapefile to the same QGIS map layout, put it just below roads and above the urban layer. Right-click on the layer, choose Properties and make the drg24 just outlines (not filled rectables, turn off the fill, make the outlines a color) so you can see through to the layer underneith. See below.

Save the work you've done on the myfirstmap.qgs layout so far. Use the Identify Features tool the find the QUADCODE and Q24SCAN values for the two rectables from drg24 that cover most of Santa Clarita. You need to select / highlight the drg24 layer to do this.

You need two DRGs to cover most of Santa Clarita. You want the "7.5_minute_series_albers_nad83_trimmed"; go back to: http://gis.ca.gov/, follow the links -> Data Collections -> California Digital Raster Graphics -> CaSIL DRG Directory, CalSpace - UC Davis, CA -> 7.5_minute_series_albers_nad83_trimmed. Find the QUADCODE folder, download the files that match Q24SCAN name. This is a "geotif" ... again, more later ... but for just know a .tif is an image, it is "raster" data format.

Close the Attribute Table and then Use Add a Raster Layer to add the DRGs you just downloaded. Zoom in to some part of Santa Clarita you are familiar with to see what a DRG looks like up close.

Turn off the state_highways layer. Add the local_roads data layer, this is a large vector dataset and might take a while to draw. Make the local_roads thicker lines, give them a color.

Why don't they line up? Look at the metadata for local_roads, what scale were these data compiled at? What is there source? What was the printed map scale of the DRG? Is it reasonable to expect these two data sources to line up perfectly? Approximately, take an average of four measurements, is the offset between intersections in local_roads and those same intersections in the DRG?

* Turn off the local_roads

4. About map projection, coordinates and scale

How a GIS deals with coordinate systems and map projection is important. This is at the core of what GIS is, it is software for viewing and manipulating spatial data. What makes data spatial is their coordinate system. Now we are going to tell QGIS what coordinate system our data are projected with. Luckily, you can thank me later, all the data you are using for this lab are in the exact same projection. What is that projection?

Go back to the webpage where you found the *_trimmed directory (where downloaded the DRG), at that level in the directory structure you will see something called projection. In that file there is something with Albers in it ... and it's wrong ... these data are not NAD27 despite what that file says ... the are NAD83. The state of California has it's own projection. What are the units?

Once you have figured out the projection and units, go to QGIS and look for Project Properties. Under General specify the map units as feet. Under Projection scroll down until you see Projected Coordinate Systems, turn the plus to a minus to expand it and see the list of predefined projections that QGIS supports. Select the correct one, then check on "Enable on the fly projection" - Now you can turn on the scale bar, and the distances will be in whatever map units (the projection's units can be different than the map's units), and the scale will make sense. Add a scalebar to somewhere on the map that looks best.

Save the map you just made to a .jpg (File -> Save as Image) to C:\WorkSpace\qgis_lab\, name the file myfirstmap_<lastname><six digit date>.jpg, you will turn this in (email to me) when you are done with the lab.

4.1.1 - Measure a distance from ADI to COC

How far is it from CCC campus to COC campus? I'm not too particular about how precisely you determine where the start and end points are, just so long as it is "close" (close as in hand grenades, horse shoes, and tactical nuclear weapons). Turn off all the layers except the DRG, add the other DRG you downloaded. With the Measure tool estimate the path distance as is shown below.

What is this distance in kilometers and miles?

Now extimate the area convered by the two DRGs. In sq. km, sq. mi, and ac. Write these numbers down, you will email to me along with your maps when you are done.

* Turn off the DRGs and drg24

4.1.2 - Measure a distance from LA to SF

How far is it from Santa Barbara to Santa Clarita from centroid (center of the polygon) to centroid?

Use http://www.google.com Maps to "get directions" for Santa Barbara, CA to Santa Clarita, CA, how far does it say the distance is? Measure the distance using QGIS for Santa Barbara to Santa Clarita. Use only four clicks (segments) to roughly approximate the shape of the roads connecting the two points. Maximize QGIS and set the extent so Santa Barbara is on the left edge of the window, and Santa Clarita is on the right. What is this distance in miles?

Does Google use a straight "as the crow flies" distance or does it use path distance? How far is it from LA to SF? Zoom out and use the roads shapefile for this. Again, how precisely you determine the start-end points is up to you so long as you are close. What is this distance in miles?

4.1.3 - How big is CA?

Now, find a shapefile that has the boundaries of all the Counties in the CA. Go to http://gis.ca.gov/ -> Data Collections -> Frequently Accessed Data, find and download a counties shapefile to C:\WorkSpace\qgis_lab\data\. Remember that a shapefile consists of multiple files (download all the necessary files to your \data\ folder and add it to your QGIS map). After you find the counties shapefile estimate the area of CA using the QGIS Measure Area tool. How big is CA in sq. mi, sq. km, and ac? How "tall" is CA from the southern most end to the northmost end (in mi)?

With the measure too estimate length of the coastline. How long is the coastline in miles and kilometers? Use only five clicks (segments) with Measure tool to approximate the shape.

-- STOP --

*** below progress, out of date


5. Make a simple map

Topography can add significantly to simple maps, by far the most common method is with a hillshade image. What is a hillshade? It's much like what it sounds like.

Take some time and look at the folders and files in /casil/maps/hillshades/ (http://gazetteer.casil.ucdavis.edu/casil/maps/hillshades/) Check out hil30m_color_v2.tif vs. hil30m_color_v2.sid, What is a .sid file?

Now, with Windows Explorer, go to your data directory and check out the .prj file, right-click on it and choose Open. Use that "Open with" dialog to find Microsoft Office Word, click OK. Or, if you don't want to deal with this, just look at the screenshot below.

What opens in Word is generically called a "projection file", it has PARAMETER that GIS software uses to define the map projection and units used to display geographic data.

5.1 Find Data

Go to CaSIL and locate a counties (Administrative Boundaries) shapefile, download the shapefile to your \data\ directory.

5.2 Add the Hillshade raster to QGIS

Using QGIS open the (raster) hillshade geotiff. With QGIS do Save As ... and save the QGIS map layout.

Zoom all the way out to the maximum extent, then zoom in so just Southern California is shown. Put the state_highways as the top layer, the urban boundarie polygons as the second, and the hillshade raster underneath. Change the symbolization (line color, line style) of the roads and county layers. Right-click, choose Properties, then in the Symbology tab. See screenshots below. Use whatever colors, line styles / thickness, you think looks best.

Under the Symbology tab make the Fill Patterns choose the one that is hollow (empty), and change the Outline Style and color. Try adding the urban boundaries polygons and experiment with Transparency.

Save your QGIS map layout. Mess around with the Symbolization for the roads and county layers until you are satisfied. I generally avoid using straight black, and use dark gray instead, dashed lines are fine but if you like solid lines better that is fine too. This is your map. Once you are satisfied with your map, go up to File -> Save as Image, navigate to your qgis_lab folder, choose JPEG as the File Type.

Once you have your map exported as a JPEG, start PowerPoint (go to Start -> Programs -> Microsoft Office -> PowerPoint). Insert the JPEG image into a slide (Insert -> Picture -> From File...)

NOTE: The following screenshots for PowerPoint are from Office2003. Office2007 PowerPoint is different, we will be working through this together.

Next you need to draw a box around the edge of the map (called a "neatline"), click on the rectangle looking icon and draw a box, then change the Fill to "No Fill"

Next, with the neatline still selected, change the line thickness.

Next Insert a Textbox for the map's title.

Now insert a few more textboxes for the Counties, and arrows if necessary. See example below ... but do not just duplicate it! This is your map, other than the requirement that it have a title with Southern California and Counties in it, use a map you make in QGIS, and have Data Sources and Created by, it's really up to you. I want it to look similar to this but not exactly like this. Feel free to use whatever line colors, styles, fonts, etc. that you want. Experiment.

NOTE: do not get frustrated, if you are not familiar with PowerPoint ask for help! (please)

Save your PowerPoint file in your qgis_lab folder, from PowerPoint do File -> Save As. Under "Save as type" choose JPG. Attach the .jpg to an email, and email it to me with email's subject having G151 in it "my first map" (or something cheesy like that).

The End

created by jeff 9/7/06, last outdated 9/08