Lab Assignment #1 Introduction To Geographic Data 1. Logistics
Lab Assignment #1 Introduction To Geographic Data 1. Logistics
Bodo Bookhagen
Lab Assignment #1
Introduction to Geographic Data
1. Logistics
Date assigned: Tuesday, October 15, 2019
Points: 20 points
In this lab, you will work with two types of geographic data (vector and raster) in a desktop
environment. We will show how to make maps using common geographic data, and what
elements should be included on all assignments. We will also discuss software needs for the
class.
2. Introduction to QGIS
In this section, we will do a brief introduction QGIS, an open-source GIS (geographical information
system) software. If QGIS is not already installed on your computer, you can download it here:
http://www.qgis.org/en/site/forusers/download.html. QGIS is built on the gdal framework
(http://www.gdal.org/index.html), which should be included in the QGIS installation process. While gdal
provides powerful geographic processing tools on the command line or in Python, QGIS allows for a
“friendly” user interface for creating and analyzing maps. You will continue to use QGIS over the next
weeks’ labs, so today we will focus on getting familiar with the software and making a simple map.
The geospatial data you will work with comes in two primary forms: vector data are non-gridded shapes
or lines (e.g., streets, city boundaries) that may or may not have directional or magnitude information
(e.g., GPS geodetic data). In this lab, we will first load simple polygons of continent borders.
In QGIS, navigate to the left-hand toolbar. The top button should be ‘Add Vector Layer.’
Click on this and, in the dialog box choose to Browse for datasets and open
‘Continent_Outlines.shp’
When you try to open the shapefile, you will be prompted by the dialog box Coordinate
Reference System Selector. The data should be loaded in ‘WGS 84 / EPSG: 4326’. (This
will probably already be selected). Select this coordinate system and load the data.
Raster data are gridded datasets that provide pixel-based information, like a digital photograph. Rasters
may be single-band (e.g., black and white image) or multiband (e.g., RGB image). In this lab, we will load
a single-band digital elevation model (DEM), in which every pixel represents an elevation on Earth’s
surface.
Beneath the ‘Add Vector Data’ button is the ‘Add Raster Layer’ button. Select this and follow the
same procedure to load the raster file, ‘gtopo_dem_6m.tif’.
Again, be sure to load the data in the ‘WGS 84 / EPSG: 4326’ coordinate system.
You should now have a map that looks something like this:
You can change the appearance of the data currently displayed in your map by the layer properties,
accessible by right-clicking each layer in the Layers Panel.
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
The vector data should be ‘hollow’ so we can see the elevation data underneath. For example:
The elevation data should be symbolized with a color scheme that provides a reasonable differentiation
between low elevation, high elevations, and oceans, such as that above. You can manually edit the bin
values by clicking the numbers in the ‘value’ column.
Now, since we have elevation represented by color in the DEM, we can place the raster data on top of
the raster data by dragging the vector up the list – layers are drawn from the top down in QGIS (and
most GIS systems).
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
Note that the oceans are likely a weird color – this is because they are defined as ‘zero’ in our dataset,
and there are also areas of the world with an elevation below zero. To change this, we need to define a
‘nodata’ value for the dataset. Some datasets have this already defined, and some do not. We can check
this under properties – transparency:
If we then rescale our color map, we should have a nice map that excludes the oceans. We can look for
additional colormaps under ‘create new color ramp’:
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
Switch the Print Composer window. Go to Layout ‣ Add Map. Use your cursor to draw a rectangle in the print
composer. You will see that the rectangle window will be rendered with the map from the main QGIS canvas.
The rendered map may not be covering the full extent of our interest area.
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
You can use the ‘Select/Move Item’ and ‘Move Item Content’ to fit the map to display only the regions
with data.
Once you’ve adjusted the project to display only the data you desire, we will add a grid and zebra border
to the main map. Select the Map 0 object from the Items panel. In the Item properties tab, scroll down
to the Grids section. Click the Add a new grid button. By default, the grid lines use the same units and
projections as the currently selected map projections. However, it is more common and useful to display
grid lines in degrees. We can select a different CRS for the grid. Click on the “change...” button next
to CRS.
In the Coordinate Reference System Selector dialog, enter 4326 in the Filter box. From the results, select
the WGS84 EPSG:4326 as the CRS. Click OK. Select the Interval values as 10 degrees in
both X and Y direction. You can adjust the Offset to change where the grid lines appear.
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
Scroll down to the Grid frame section and select the zebra frame.
To finish the map, include a Legend, Scale Bar, and North Arrow. Legends and scale bars are easily added
with the ‘Add new legend’ and ‘Add new scalebar’ features. To insert a north arrow, you will need to use
the ‘Add north arrow’ feature. Holding your left mouse button, draw a rectangle on the top-right corner
of the map canvas.
Finish by adding a title to the map using the ‘Add new label’ feature.
Question 1: Download your own data, create a simple map, explain where you got the data, scale bar,
color palette/legend. There are many resources where you can download data and many datasets that
might be interesting to you. A good resource is the University of Maryland’s Global Land Cover Facility
(http://glcf.umd.edu/data/), USGS EarthExplorer (https://earthexplorer.usgs.gov/), Natural Earth
(https://www.naturalearthdata.com/). You will need to create an account, but registration is free. Feel
free to download data for any region of interest to you. Important – Do not simply turn in a map of the
elevation data! It is important to find your own data to map for this assignment. (10 points)
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
A hypsometric curve is an empirical cumulative distribution function of elevations in a given area. This
can be small catchments, an entire drainage basin, a continent, or a rectangle of any area. A
hypsometric curve shows the occurrences (or probability distribution) of topographic elevation.
Comparing the elevation distributions of different areas is a simple way to compare the topography of
different regions. We can create a hyposmetric curve for the whole globe using QGIS:
Notice the large spike of values at zero, which is actually the coastlines. QGIS’s simple histogram
function still takes account of the nodata values we set in ‘Transparency’. We can test this by turning off
the nodata value and running the histogram again.
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
Let’s take a second look at our ‘continents’ shapefile. There are several fields in the dataset that we can
symbolize.
If we open this, we get a table describing each of the shapes in the layer. Notice that each continent is
given a label, length, and area. We can symbolize each continent with a different color based on the
names by changing the symbology to ‘categorized’:
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
While the global hypsometry is interesting, a comparison of the histograms for each continent will be
much more useful. To do this, we need to do two mains steps: (1) Select individual continent shapefiles,
and (2) clip the elevation data to the extent of those continents. We can do all of this from within QGIS.
First, let’s clip out one of the continents. QGIS includes an easy split function for just such a case:
We can define a save location, and it exports several datasets in the gpkg format, which maintains color
and other information as well.
Now that we have each of the continents as a single shapefile, we can go about clipping our elevation
dataset one continent at a time. Load in one (or all) of the shapefiles and use the ‘Extract by Mask Layer’
tool:
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
On the bottom you will see the command that QGIS is actually running, which we will return to later in
this course. If you are running tools on the command line, you can also copy and paste that line of code
to your terminal and create clipped files that way.
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen
You can also export the histogram as raw data with the ‘Raster Unique Values Report’ tool:
This allows you to save the number of pixels with each value to a text file or excel spreadsheet.
Question 2: Using the tools found in this lab, create a single image showing the histogram of elevations
for each continent. You are welcome to create the histogram in whatever program you choose (e.g.,
python, Excel, R, matlab, etc). Hint: The easiest way to do this is likely to export each set of counts to a
separate table and then combine them with another tool. See below for a possible acceptable output
(10 points).
Institute of Earth- and Environmental Science – Remote Sensing of the Environment – Lab Exercise 1
Bodo Bookhagen