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/analysisfolder and name itpr-elev-analysis. - Add the 
PRI_adm0.shp. - Right-click on 
PRI_adm0and selectProperties.... - Select the 
Symbologytab and then click onSimple Fill. - Next to the 
Fill styleand select theNo brushoption. 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 Managerbutton and select theRastertab. - Navigate to 
intro-gis-data/PR_SRTMand select thesrtm_23_09.tiffile. - Click 
Addand 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_09as the input file, andPRI_adm0as theMask layer. - Choose the 
Project CRSas 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-clippedin theintro-gis-data/outputsfolder. - Click 
Runand close the window. Save the project. - Open the 
srtm_23_09layer properties and select theInformationtab. Under theInformation from providersection, scroll down to view the Pixel Size. It should be about0.0008333, or around90meters around the equator. - Remove the 
srtm_23_09layer. 
Next, change the symbology for a better visualization of the elevation.
- Navigate to the 
Symbologytab of thesrtm_23_09layer properties window. - Next to the 
Render typefield, chooseSingleband pseudocolor. - Choose a predefined color ramp from the 
Color Rampdropdown menu, or selectCreate new color ramp...from theColor rampdropdown menu and selectCatalog: cpt-cityand pressOK. - From here, select the 
Topologytab to select options specfically designed for elevation visualization. Select one and pressOKto close the pop-out window. - Click on the 
Transparencytab. Adjust theGlobal Opacityto50%, then pressOKto close thePropertieswindow. 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_clippedas 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 (0to90degrees). - 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-hillshadein theintro-gis-data/outputsfolder. ClickRunand 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, andSaturationin theLayer Renderingportion of theSymbologytab in thePropertieswindow. - Click 
OKand 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-clippedlayer to be beneath thepr-hillshadelayer in the Layers panel. - Set the hillshade layer to be transparent by clicking on the 
Transparencytab in theLayer Propertieswindow. - Set the 
Global opacityof 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.