TUTORIAL NO.
05
NAME OF TUTORIAL: 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.
A. Loading Raster Data
Raster data can be loaded with the same methods we used for vector data. However we suggest
to use the Browser Panel.
1. Open the Browser Panel and expand the exercise_data/raster folder.
2. Load all the data in this folder:
• 3320C_2010_314_RGB_LATLNG.tif
• 3320D_2010_315_RGB_LATLNG.tif
• 3420B_2010_328_RGB_LATLNG.tif
• 3420C_2010_327_RGB_LATLNG.tif
You should see the following map:
39
B. Create A Virtual Raster
Our solution layer lies across four images. Which means that you have to work with four raster images
all the time, which is not ideal. It would be better to have one file to work with.
QGIS allows you to do exactly this, and without needing to actually create a new raster file. You can
create a Virtual Raster. This is also often called a Catalog. It’s not really a new raster. Rather, it is a
way to organize your existing rasters into one catalog: one file for easy access.
To make a catalog we will use the Processing ► Toolbox .
1. Open the Build virtual raster algorithm from the GDAL ► Raster miscellaneous ;
2. In the dialog that appears, click on the … button next to the Input layers parameter and
check all the layers or use the Select All button;
3. Uncheck Place each input file into a separate band . Notice the code that is generated at the
bottom of the dialog under GDAL/OGR console call . This is the command that will be
executed when you click Run . The text updates as you change different options in the dialog.
4. Finally click on Run .
40
You can now remove the original four rasters from the Layers Panel and leave only the output
virtual catalog raster.
MERGING RASTERS
If you need to create a new raster layer and save it to disk you can use the merge algorithm.
1. Click on the Merge algorithm from the GDAL ► Raster miscellaneous menu.
2. As we did for the Create a Virtual raster, use the … button to choose which layers you
want to merge.
You can also specify a Virtual raster as input, and then all of the rasters that it consists of will
be processed.
3. If you know the GDAL library, you can also add your own options by opening
the Advanced parameters menu.
41
C. Changing Raster Symbology
1. Use the Browser Panel to load srtm_41_19.tif , found
under exercise_data/raster/SRTM/
2. Zoom to the extent of this layer by right-clicking on it in the Layers panel and
selecting Zoom to Layer .
This dataset is a Digital Elevation Model (DEM). It is a map of the elevation (altitude) of the
terrain, allowing us to see where the mountains and valleys are, for example.
While each pixel of the dataset of the previous section contained color information, in a DEM,
each pixel contains elevation values.
Once the DEM is loaded, you will notice that it is a grayscale representation:
Within the Layer Properties dialog, right-click on the layer in the Layer tree and select
the Properties option. Then switch to the Symbology tab.
42
The default Color gradient is set to Black to white, meaning that low pixel values are black
and while high values are white. Try to invert this setting to White to black and see the results.
The above image in grayscales is not always great styles for raster layers. Let’s try to make
the DEM more colorful.
1. Change the Render type to Singleband pseudocolor . If you don’t like the default
colors loaded, select another Color ramp
2. Click the Classify button to generate a new color classification
3. If it is not generated automatically click on the OK button to apply this classification
to the DEM
43
You’ll see the raster looking like this:
---X---End---X---
44