Part 2 - Exploring the Interface

The goal of part 2 is to familiarize you with the interface and basic features of GIS in general and QGIS in particular. You'll also add and configure some layers that you'll use later in Part 3.

I. The QGIS Interface II. Adding Vector Data III. Exploring the Map View IV. Exploring Features V. Adding Raster Data VI. Saving Your Project

Section I: The QGIS Interface

This section will introduce you to the QGIS interface; you will configure the interface in preparation for the rest of this tutorial.

Turn toolbars on and off

Steps

  1. Configure plugins. Go to Plugins > Manage Plugins. Make sure the following three plugins ARE checked: Add Delimited Text layer, GdalTools, and ftools. Turn off all the other plugins.
  2. Configure the toolbars. Right click on a blank area of the tool bar to get the tool bar view menu. Make sure the following two features are NOT checked: Undo / Redo and Advanced Digitizing. Make sure all of the other options are checked.
  3. Move toolbars. Move the toolbars around by hovering over the left edge of a toolbar until you see a crosshairs, left click and hold, then drag and drop. Configure the toolbars to your liking (suggestion: try aligning them so you have only two rows of them at the top of the screen and all buttons are visible)

Commentary

  1. Menu Bar: provides access to various features and functions of the software using a standard hierarchical menu. The location of the menus and menu items is fixed, although if you activate certain plugins they may add an additional menu to the bar.
  2. Tool Bar: replicates many of the features and functions in the Menu Bar, providing access to common features in a single click. The location of the toolbars is not fixed; if you hover over the edge of the toolbar and hold down the left mouse button you can drag and dock the toolbar wherever you like (this means that the location of tools on your screen may not match those of other screens, or this tutorial).
  3. Map Legend: a list of the map layers that are part of your current project. You can check or uncheck layers to turn them on and off, drag them to change the drawing order, select one in order to perform specific tasks on that layer, and right click on a layer to access menus and tools for working with that specific layer.
  4. Map View: geographic display that shows all of your active layers.
  5. Map Overview: you can add a layer to this overview to act as a frame of reference for the layers in your map view. It shows the full extent of a layer and outlines the portion of the area currently visible in the Map View in red.
  6. Status Bar: shows the current scale of the map view, the coordinates of the current position of the cursor, and the coordinate system used by the project. Progress meters and other messages will appear here as you perform specific operations.
QGIS Interface

Section II: Adding Vector Data

In this section you'll learn how to add vector GIS files (shapefiles) to QGIS and to symbolize them. Shapefiles are a common GIS data format that you'll encounter in your future work.

Steps

  1. Examine your data. Take a look at the data files under the data folder for part 2. These are shapefiles that we will add to QGIS and work with for this project. There are four shapefiles; each shapefile is composed of multiple files that have the same names but different extensions.
    Components of shapefiles
  2. Launch QGIS. (If you're using Microsoft Windows, look under the Start Menu > Program Files > Quantum GIS > QGIS).
  3. Set the projection for the project. On the Menu Bar, go to Settings > Project Properties > Coordinate Reference Systems Tab. Scroll through the list, choose NAD83, and hit OK (for now we'll just do this step and move on; we'll discuss coordinate systems and map projections later).
    Set projection to NAD83
  4. Add the four shapefiles. On the Tool Bar, hit the Add Vector Layer button. When the Add Vector Layer box appears, hit the Browse button. Browse through the folder list to the data folder for part 2. In the Files of Type dropdown at the bottom of the window make sure the first option, ESRI shapefiles, is selected. Select the first layer in the list, hold down the shift key, then select the last layer. This should select all four shapefiles. Hit Open to add them. Your layers should appear in the Map Legend and Map View.
    Add layers to map
  5. Do your layers look jagged? If not, skip this step. If so, on the Menu Bar, select Settings > Options > Rendering SVG, and under Rendering Quality check the box that says "Make lines appear less jagged at the expense of some drawing performance", and hit OK.
    Re-order layers
  6. Experiment with changing the drawing order. Click on the first layer that's listed in the Map Legend (ML), hold down the left mouse button, and drag it to the bottom of the list. This moves that layer from the top of the drawing order to the bottom; layers in the Map Legend (ML) are stacked on top of each other, and their order in the list determines which are visible relative to others. Move the counties layer to the top of the list to see what happens.
  7. Order the layers. Drag the layers in the Map Legend (ML) so they appear in this order, from top to bottom: nyc_4yr_colleges (colleges and universities), nyc_greenspace (parks and wildlife areas), nyc_facilities (airports, ports, prisons), nyc_counties_2008 (counties / boroughs).
  8. Change the color for the colleges. Double-click on the colleges layer in the ML to open the Layer Properties menu for that layer. Click on the Style tab. Click on the box under Fill options that contains the fill color. Change the color to blue by choosing a box in the color palette. Click OK, then OK again on the Style menu.
    Style menu
  9. Change the colors for parks and facilities layers. Make the parks green and the facilities grey or brown.
  10. Give the counties no fill. (i.e. make them hollow with no color). Double-click on the counties layer in the ML to open the Layer Properties menu for that layer. Click on the Style tab. Change the option in the Fill Options drop down box to None. Click OK.
  11. Add the counties layer to the overview. Select the counties layer in the ML, right click on it and click on the Add to Overview option in the menu. After completing these steps, your QGIS window should resemble the image below.
QGIS view so far

Commentary

Shapefiles

A shapefile is a very common file format used for storing vector GIS data. It was created by a company called ESRI, the makers of ArcGIS (the predominant software in the proprietary GIS market). Shapefiles are an open GIS format that can be used in just about any GIS software package, including QGIS. A shapefile can consist of point, line, or polygon features for a given geographic area, and can never consist of multiple types of geometry (i.e. you can't have a shapefile with points and lines).

Despite it's singular sounding name, a shapefile consists of several individual files. The following three pieces are mandatory:

The following pieces are typically (ideally) included

It is important that all of the pieces of the shapefile are kept together in the same folder, otherwise the file will not work - so be careful when moving files around! Renaming files is often problematic - if you rename one you must rename all of them with the same name, otherwise they won't function together. You can easily rename batches of a file with the same name but different extensions if you are familiar with using the command line (i.e. Unix/Linux shell or DOS Command Prompt); it's less tedious than renaming them by hand in a GUI (like Windows Explorer).

Adding Data to a Map View

When you add map layers or data to a map view, you are technically not adding data to the window, i.e. copying the file and inserting it into the project. Rather, you are establishing a link between the GIS interface and the files, which exist independently from the software. When you use GIS software to change the symbolization of the layers (colors, outline, labels, etc) you are not modifying the data file itself; you are simply telling the software to display the layers in a certain way. The software is essentially a window for viewing the data files. The only way to change the data files themselves (their geometry or attributes) is within an editing mode which you must specifically launch.

Drawing Order

For much of the 20th century maps were created by taking individual layers on translucent mylar sheets and laying them over top of a paper base map. For example, an outline of the United States with boundaries of each state could serve as a paper base map, with individual mylar sheets layered on top that had rivers and cities. The order of the sheets determined which features appeared on top, covering up other features. GIS functions the same way; the order of the layers determines which appear on top. If you move a polygon layer with a solid fill (i.e. counties) over top of a point layer (i.e. of schools), you will not see the schools as the county layer is covering it up. In order to show both layers, you would have to move the school layer on top of the counties.

Alternatively, you could make the counties layer hollow by removing the fill, which would allow the school layer to be visible if it was on the bottom. This solution isn't ideal, as the boundary lines of the counties would partially cover a school if that school was located on or near a boundary. Typically, you would use a hollow fill for a polygon if you wanted to display it's boundaries on top of another polygon layer that has a fill.


Section III: Exploring the Map View

In this section you'll learn how to navigate the map view.

Steps

  1. Experiment with the Zoom tools. Try each of the zoom tools in the Menu Bar.
    • Zoom In - click to zoom in once, draw a box to zoom in to an area, or use the mouse wheel.
    • Zoom Out - works the same as the Zoom In tool
    • Zoom to Native Pixel Resolution - will zoom to the optimal scale for rasters (skip this one for now)
    • Zoom Full - will zoom the window to the maximum extent of all visible layers
    • Zoom to Selection - zooms to selected features (skip this one for now)
    • Zoom to Layer - zooms to the maximum extent of the feature currently selected in the ML
    • Zoom last - returns to your previous zoom
    • Zoom next - moves you forward to your next zoom (if you've already used zoom last)
    • Refresh - redraws the screen (useful if your layers didn't draw completely or properly)
    • Pan - move around the map by holding the left mouse button down and drag (does not change the zoom)
  2. Notice change in coordinates. Move the cursor around the map. In the Status Bar (below the Map View) notice how the coordinates change; coordinates for the map are provided based on the position of the cursor. The unit of measurement is determined by the coordinate system and map projection of the project (since the project is in NAD83, the coordinates are in degrees and represent latitude and longitude). The scale box can also be used to change the zoom (a higher number to zoom out and a lower number to zoom in).
    Status bar
  3. Measure some distances. Use the zoom tools to center Manhattan in your map window. Select the measuring distance tool in the toolbar. You'll notice that crosshairs will appear. Click on the northern tip of Manhattan. This will open the Measure window. Drag the crosshairs to the southern tip of Manhattan. As you do this, you'll see a black line is drawn from the original point you clicked on and the measurement window will update with distances in meters and kilometers. If you click on the southern tip of Manhattan it will lock the line segment and allow you to draw a second segment from the second point. Close the menu when you've finished experimenting.
    Measure Window
  4. Change your measurement units. Go to Settings > Options > Map Tools tab. In the Measure Tool section under Preferred measurement units select the feet radio button. Under Ellipsoid for distance calculations dropdown change the values from WGS 84 to GRS 80 (What's this? See below). Hit OK. Try the measuring distance tool again and your units will be in feet and miles.
    Map Tools tab

Commentary

Measuring Distances and Area

The way that QGIS handles measuring distance, area, and angles has become easier with version 1.7. In previous versions the default was that the units of measurement were based on the units used in the project's coordinate system. Since NAD 83 uses degrees this tool wasn't very helpful, and you had to change a few settings to get it to work properly (if you uncheck the ellipsoidal box in the Measurement window the units will revert to the project units - in this case degrees).

However, you still need to be familiar with your project's and your layer's coordinate system in order to avoid errors in measurement. The measurement tool bases it's measurement on the ellipsoid, or approximation of the earth's shape, in the Ellipsoid for distance measurements dropdown. If this ellipsoid doesn't match the one your project or layers are in you can get false measurements. How did we know that NAD 83 uses GRS 80? If you go to Settings > Project Properties and look at the definition for NAD 83, you'll see that GRS 80 is listed within the definition.

We'll cover coordinate systems and projections later on in this tutorial. The default CRS used by QGIS (WGS 84) is actually quite similar to NAD 83; in this case any errors in measurement would be quite small.


Section IV: Exploring Features

In this section you'll learn how to explore and interact with features in the Map View and Attribute table.

Steps

  1. Identify features. Hit the Identify Features button in the Tool Bar. Select the counties layer in the ML. Click on Manhattan. Manhattan is hi-lited and information about that feature is displayed. Click on The Bronx to change the selection.
  2. Identify features from a different layer. Make the colleges layer the active layer by selecting it in the ML. Click on any school in the map view to get information about that school. Where is this information coming from?
    Identify a college
  3. Open the attribute table. With the school layer still selected in the ML, right click on the layer and select Open attribute table (alternatively, you could click the Open Attribute Table button on the toolbar). For every school (feature) in the school layer, there is a record for the school in the attribute table of that layer. Explore the table by scrolling across it and down.
  4. Select a feature from the table. Sort the table by clicking on the field (column) heading that contains the name of the school (FACILITY_N). Click on the record for Bernard M Baruch College in the table. Close the attribute table. Zoom to the area around Baruch in lower Manhattan and you'll see it is selected. (Note - you can select multiple records from the table by holding down the CTRL key and selecting records one by one, or select a range by selecting a record, hold the SHIFT key, and select the last record).
    Select college in the attribute table
  5. Select a feature from the map. With the school layer still selected in the ML, hit the Select Feature button in the toolbar. Then select the school that is just to the east (right) of Baruch College. Hit the Open Attribute Table button. Click the checkbox that says Show Selected Records Only. This reveals the record for the School of the Visual Arts; this is the school that you've selected in the Map View. These two steps demonstrate that the table and map are linked, and you can select features in one and display them in the other. (Note - you can select multiple features by holding down the CTRL key and clicking on features one by one, or by hitting the dropdown beside the Select Feature button and choosing one of several options).
    Select college in the map view
    View selection in attribute table
  6. Select Features by Attribute. With the Attribute Table for the schools open, click the Advanced button in the lower right-hand corner. This opens the query builder window, which allows you to select features based on shared attributes. In the Fields box, double-click the BOROUGH field, which adds it to the SQL Clause box at the bottom. Click on the equals sign in the Operators section. Hit the All button under the Values box to display all of the unique values for the BOROUGH field. Double-click on the 'BX' value listed in the value field. Your statement in the SQL Clause box should read BOROUGH = 'BX'. Click OK. You've just selected all of the schools that are located in the Bronx. Close the attribute table and you'll see the schools selected in the map.
    SQL query builder
    Selections in map view
  7. Clear selected features. Click the Clear Selected Features button on the tool bar to remove selected features in the active layer (the active layer is the currently selected layer in the ML hi-lited in blue - in this case, the college layer). Alternatively, you could click on an area of the map that has no schools to clear the features, or you could clear the current selection from the attribute table.
  8. Labeling features. Attributes stored in the table can also be used to label features. Double click on the school layer in the ML to open the Layer Properties. Go to the Labels tab. Check the box in the upper-left hand corner that says Display Labels. In the dropdown box beside Field contains labels, choose FACILITY_L as the label field. Change the value in the Font drop down menu to font size to 8. Change the Placement radio button to Above Right. Hit OK. Explore the map a little. When you're finished, turn the labels off by returning to the labels tab in the properties menu for the layer and unchecking the box that says Display Labels. We'll experiment more with labeling later on.
Labels menu

Commentary

Attribute Tables

Every feature in the map view has a record in the attribute table; you can't have a feature without an attribute or vice versa. In a shapefile, the geometry is stored in the .shp file, an index of the geometry is in the .shx file, and the attributes are stored in a .dbf file. As we'll explore throughout this tutorial, attributes can be used for selecting, symbolizing, and labeling features in layers.

In GIS software attribute tables are managed and handled in the same manner as tables in a relational database. Each column has a data type associated with it which determines the kind of data that can be stored in that column and the types of operations that can be performed on it. Data types include strings (aka text) and various types of numeric fields (integers for whole numbers, reals for numbers with decimal places, etc). When you use the Query Builder to select features, like BOROUGH = 'BX', you are actually creating SQL code, which is a standard language for manipulating data in a database. The code 'BX' must be surrounded by quotes, as that is standard procedure when querying string (text) fields in SQL; if we were querying numeric values we would not use quotes.


Section V: Adding Raster Data

In this section you'll get a very brief introduction to raster data.

Steps

  1. Add raster data. Hit the Add Raster Layer button on the toolbar. Browse to the data folder for part 2, select the drg_central_park.tif file and add hit open. Once the layer is added, drag it to the bottom of the ML.
  2. Explore raster layer. Select the drg_central_park layer in the ML. Right click on the layer and select Zoom to best scale (100%). Explore the area of the map around Central Park and note how the raster layer lines up with the other layers. Select the parks layer in the Map Legend. Double click to open the Layer Properties and go to the Style tab. Drag the transparency slider to 25% and click OK. When you're finished exploring the map, uncheck the raster layer in the ML to turn it off and turn the transparency of the parks layer back to zero.
USGS Raster

Commentary

Raster Data

Raster layers differ from vector layers in many ways including composition (continuous surface of pixels versus discrete geometric areas), file formats (many raster formats versus relatively few vector formats), resolution (optimal scale for raster layers matters more than vector layers), size (raster files tend to be much larger), and attribute tables (raster layers do not have attribute tables; the color of individual pixels denotes feature values). Given the differences in format, the tools for working with vector and raster layers are distinct (if you double click on the raster layer to open its properties, you'll see that most of the menu options are different from the vector layers).

Many geographic objects are represented in raster formats including satellite imagery, aerial photography, paper maps that have been scanned and digitized, and imagery that has been interpreted to represent value-added data that does not conform to political boundaries, such as land use and land cover and population density.

Up until recently the tools for working with rasters in QGIS have been limited, but this has changed with the addition of several plugins such as the gdal plugin, which allows you to perform raster analysis, and the georeferrencing plugin, which allows you to convert non-GIS image files (i.e. a scanned paper map) to a raster GIS file by assigning coordinates to it. Given the time constraints of this tutorial, we're not going to cover rasters beyond this point. It was introduced here to give you a more complete picture of GIS capabilities and data formats.

The raster used in this exercise is a DRG (digital raster graphic) which is a digitized, georeferenced version of the USGS' topographic maps. USGS topos are useful for studying elevation and terrain (particularly in non-urban areas) and for providing a frame of reference for overlaying vector layers or creating new ones; however most of the topos are several decades old and should be used with that fact in mind. The DRG was stored in a special .tif format called a GeoTIFF; a lossless image file that has georeferencing information (coordinates and map projection) embedded in it.


Section VI: Saving Your Project

You'll learn how to save your project.

Steps

  1. Change paths of files from absolute to relative.Under Settings > Project Properties > General Tab, for the last option in the General Settings area labeled as Save Paths, change the drop down box item from Absolute Paths to Relative Paths.
    Changing to relative paths
  2. Save your project. Hit the Save Project button. Navigate to the data folder for part 2, and save your project there as part2.qgs. The project file saves the symbolization, labeling, and current zoom for your data, and links to your data files (shapefiles); the shapefiles themselves are NOT stored inside your project file and exist independently. In order to use your project in the future, the project file and the shapefiles you used must be kept together.

Commentary

Project Files

When you add data to a project file you are not saving the data (shapefiles) inside the project; you are saving links to those files. Things like symbolization, data classification, the extent of your last zoom, and any finished maps you create are stored in the project file. When you click on the project file to open it, the software looks at the paths to your data, re-establishes the links, and then applies the settings (symbols, zoom, etc) that you have saved in your project file. This relationship is of crucial importance when it comes time to move or share files - if you move your project file or your data the links between them can become broken, and you'll need to re-establish the location between the project and the data in order to repair your project file.

If you open a project in QGIS and your project file can't find the data, because the data has been moved or renamed, the software will give you the opportunity to restore the link by asking you to browse through your file folders and select each file that corresponds to a layer you have in the ML of your project. Once you restore the links, you can save the project and it will save the new links.

Re-establish broken links

Paths to files can be stored as absolute links or as relative links. An absolute link contains the complete path of a file, such as AS F:\My_Stuff\GIS_Practicum\part2\data\counties.shp. Use absolute paths when you're working in an established environment where you know that you won't need to move data and projects around, or in situations where your project files won't be stored directly above or in the same folder as your data. Absolute paths are a bad choice if you know you'll be moving data around; they're a particularly bad choice if you're working on a usb drive in a MS Windows environment, as the paths can change as you move from machine to machine (i.e. F:\My_Stuff... on one machine becomes E:\My_Stuff... on another machine; QGIS won't be able to locate the files stored on F:\My_Stuff because it doesn't exist that way on the 2nd machine).

Relative paths save the directory and file information for the folder the project file is in (i.e. path would be .\county.shp) and all folders below it (i.e. path would be .\data\county.shp). Since anything above the project's directory is omitted, relative paths are a good choice if you know that you'll be sharing your project data or moving it around. Relative paths are a bad choice if your data is not going to be stored underneath your project folders (i.e. it's stored above the project directory, in a parallel directory, or another drive or server all together).

Think carefully about where to save project files in relation to your data, and once you've created your project file keep project files and data in a consistent place. Also remember that you must keep all of the individual components of the shapefile together (.shp, .shx, .dbf, .prj, etc); otherwise the shapefile will not function. If you want to share your project file with someone, you will also have to send them your data; the project file cannot exist independently from the data. You can share views or maps you've created in a static format (image file or PDF) that is separate from your project and data files; we'll explore that later in this tutorial.

The QGIS project file (.qgs) is actually just an XML file. If you open the project file in a text editor, you'll be able to see the structure of the file and all of its elements and attributes.

<--- Back     Next --->