Making a Map with Raster Data
Raster data is quite different from vector data. Vector data has discrete features with geometries constructed out of vertices, and perhaps connected with lines and/or areas. Raster data, however, is like any image. Although it may portray various properties of objects in the real world, these objects don’t exist as separate objects. Rather, they are represented using pixels with different values.
Objectives
- Learn how to work with raster data in QGIS.
- Use raster data to create a DEM and Hillshade map.
Raster Data
What is raster data? Raster data is any pixelated (or gridded) data where each pixel is associated with a specific geographical location. The value of a pixel can be continuous (e.g. elevation) or categorical (e.g. land use). A geospatial raster is accompanied by spatial information that connects the data to a particular location. This includes the raster’s extent and cell size (resolution), the number of rows and columns, and its coordinate reference system (or CRS). The spatial extent is the overall geographic coverage of the spatial object (edge or location that is the furthest north, south, east and west). A resolution of a raster represents the area on the ground that each pixel (cell size) of the raster covers.
[IMAGE raster data]
How is raster data stored? Raster data can come in many different formats, from a standard file-based structure of TIFF
, JPEG
, ASC
, PRJ
, CLR
, etc. to binary large object (BLOB
) data stored directly in a relational database management system (RDBMS
).
Exercise 2.1. Create a DEM and hillshade map.
- Open QGIS and start a new empty project. Save the project in the
intro-gis-data/analysis
folder and name itpr-elev-analysis
. - Add the
PRI_adm0.shp
. - Right-click on
PRI_adm0
and selectProperties...
. - Select the
Symbology
tab and then click onSimple Fill
. - Next to the
Fill style
and select theNo brush
option. PressOK
.
Now, we can add the SRTM elevation data. The SRTM data can be added indirectly or directly in QGIS. The indirect way uses the SRTM data provided by CGIAR and produces a 90 m resolution DEM. The direct way uses SRTM data from NASA and gives a 30 m resolution. The indirect method is faster. Those who have an EarthData login can use the NASA EarthData website and download the SRTM directly in QGIS. Both methods are described below for future reference, though the data has already been downloaded for you and can be found in intro-gis-data/PR_SRTM
.
Indirect Download
- Go to the CGIAR SRTM website.
- Select the tiles that cover your area of interest. [IMAGE srtm tiles]
- Click on
Search
. - Download the SRTM tiles that cover the study area.
- Extract the zip files to your folder of choice.
- Add the SRTM tiles to QGIS.
Direct Download
- Go to https://urs.earthdata.nasa.gov/ and login.
- To download SRTM data directly in QGIS, the SRTM downloader plugin has to be installed first.
- Go to
Main Menu: Plugins > Manage and Install Plugin > Search for SRTM Downloader > Install Plugin
. - Start the SRTM Downloader plugin:
Plugins > SRTM Downloader > SRTM Downloader
- Click on: Set canvas extent, set the output path to your folder of choice, and click on
Download
. - A popup window will appear to login to US EarthData.
- Click on:
Set canvas extent
, and set the output path to your destination folder, and click onDownload
. - A popup window will appear to login to US EarthData.
Now, let’s continue the exercise and add the DEM data to the map.
- Click on the
Data Source Manager
button and select theRaster
tab. - Navigate to
intro-gis-data/PR_SRTM
and select thesrtm_23_09.tif
file. - Click
Add
and close the window. - Clip the SRTM layer with the boundaries of Puerto Rico. Go to
Main Menu > Raster > Extraction > Clip Raster by Mask Layer
. Selectsrtm_23_09
as the input file, andPRI_adm0
as theMask layer
. - Choose the
Project CRS
as theTarget CRS
, and uncheck the box next toMatch the extent of the clipped raster to the extent of the mask layer
. Choose to save the file aspr-elev-clipped
in theintro-gis-data/outputs
folder. - Click
Run
and close the window. Save the project. - Open the
srtm_23_09
layer properties and select theInformation
tab. Under theInformation from provider
section, scroll down to view the Pixel Size. It should be about0.0008333
, or around90
meters around the equator. - Remove the
srtm_23_09
layer.
Next, change the symbology for a better visualization of the elevation.
- Navigate to the
Symbology
tab of thesrtm_23_09
layer properties window. - Next to the
Render type
field, chooseSingleband pseudocolor
. - Choose a predefined color ramp from the
Color Ramp
dropdown menu, or selectCreate new color ramp...
from theColor ramp
dropdown menu and selectCatalog: cpt-city
and pressOK
. - From here, select the
Topology
tab to select options specfically designed for elevation visualization. Select one and pressOK
to close the pop-out window. - Click on the
Transparency
tab. Adjust theGlobal Opacity
to50%
, then pressOK
to close theProperties
window. Save the project.
Exercise 2.2. Create/calculate hillshade.
The DEM layer shows you the elevation of the terrain, but it can sometimes seem a little abstract. It contains all the 3D information about the terrain that you need, but it doesn’t look like a 3D object. To get a better impression of the terrain, it is possible to calculate a hillshade, which is a raster that maps the terrain using light and shadow to create a 3D-looking image.
- To create a hillshade, we are going to use algorithms in the
Raster > Analysis > Hillshade
. - Select
pr_elev_clipped
as the input layer. - The algorithm allows you to specify the position of the light source: Azimuth has values from
0
(North) through90
(East),180
(South) and270
(West), while the Vertical angle sets how high the light source is (0
to90
degrees). - We will use the following values:
- Z factor:
1.0
- Azimuth (horizontal angle):
300.0°
- Altitude (vertical angle):
40.0°
- Z factor:
- Choose to save the file as
pr-hillshade
in theintro-gis-data/outputs
folder. ClickRun
and close the window. - Change the symbology settings so that the hillshade layer enhances the elevation layer with a semi-3D effect. Explore the options:
Blending mode
,Brightness
,Gamma
,Contrast
, andSaturation
in theLayer Rendering
portion of theSymbology
tab in theProperties
window. - Click
OK
and save the project. [IMAGE final elevation and hillshade]
Challenge: Customize the DEM and hillshade map.
A hillshade can also be used for aesthetic purposes, to make the map look better. The key to this is setting the hillshade to being mostly transparent. Additionally, it can be helpful to add contextual features to the map to ensure that the user can interpret it more easily.
- Click and drag the
pr-elev-clipped
layer to be beneath thepr-hillshade
layer in the Layers panel. - Set the hillshade layer to be transparent by clicking on the
Transparency
tab in theLayer Properties
window. - Set the
Global opacity
of the hillshade layer to50%
. If the effect doesn’t seem strong enough to you, you can update that value to one of your choosing. - Add lakes, rivers, and large cities to the map.
- Export the map as a PDF with a title, legend, north arrow, and scale bar.
- Save the project when you are done.