2. Lesson: Changing Raster Symbology

Not all raster data consists of aerial photographs. There are many other forms of raster data, and in many of those cases, it’s essential to symbolize the data properly so that it becomes properly visible and useful.

The goal for this lesson: To change the symbology for a raster layer.

2.1. basic Try yourself...

  • Use the Add Raster Layer button to load the new raster dataset.
  • Into your current map (which, following from the previous lesson, should be analysis.qgs) load the dataset srtm_41_19.tif, found under the directory exercise_data/raster/SRTM/.
  • Once it appears in the Layers list, rename it to DEM.

This dataset is a Digital Elevation Model (DEM). It’s a map of the elevation (altitude) of the terrain, allowing us to see where the mountains and valleys are, for example.

Once it’s loaded, you’ll notice that it’s basically a gray rectangle. It’s seen here with the vector layers on top:


That’s because its symbology hasn’t been customized. In a color aerial photograph, everything is already defined. But if you load a raster and it’s just a gray rectangle, then you know there’s no symbology for it yet. It still needs to be defined. So that’s what you should do next.

2.2. basic Follow along: Changing Raster Layer Symbology

  • Open the Layer Properties dialog for the SRTM layer.
  • Switch to the Style tab.

These are the current settings, and as we’ve seen, they don’t give us much information on the layer. Does it even have any data in it? Let’s see.

  • Change the Color map to Pseudocolor:
  • Click OK.

You’ll see the raster looking like this:


That does tell us what we need to know. There is data in this layer. But maybe we don’t want to symbolize it using these colors.

  • Open Layer Properties again.
  • Switch the Color map back to Grayscale.

But this time, to prevent it from becoming a gray rectangle again, let’s tell QGIS to “stretch” the color values. This will make QGIS use all of the available colors (in Grayscale, this is black, white and all shades of gray in between).

  • Tell it to use Custom min / max values:
  • Set the value Current of Contrast enhancement to Stretch To MinMax:

But what are the minimum and maximum values that should be used for the stretch? The ones that are currently under Custom min / max values are the same values that just gave us a gray rectangle before. Instead, we should be using the minimum and maximum values that are actually in the image, right? Fortunately, you can determine those values easily by loading the minimum and maximum values of the raster.

  • Under Load min / max values from band, select Estimate (faster).
  • Click the Load button:

Notice how the Custom min / max values have changed:

  • Click OK.

You’ll see the values of the raster properly displayed, with the darker colors representing valleys and the lighter ones, mountains:


2.2.1. But isn’t there a quicker way?

Yes, there is! Now that you understand what needs to be done, you’ll be glad to know that there’s a tool for doing all of this easily.

  • Remove the current DEM from the Layers list.

  • Load the raster in again, renaming it to DEM as before. It’s a gray rectangle again...

  • Enable the tool you’ll need by enabling View ‣ Toolbars ‣ Raster. These icons will appear in the interface:


The button on the right will stretch the minimum and maximum values to give you the best contrast in the local area that you’re zoomed into. It’s useful for large datasets. The button on the left will stretch the minimum and maximum values to constant values across the whole image.

  • Click the button on the left (Stretch Histogram to Full Dataset). You’ll see the data is now correctly represented as before!

2.3. In conclusion

These are only the basic functions to get you started with raster symbology. QGIS also allows you many other options, such as symbolizing a layer using standard deviations, or representing different bands with different colors in a multispectral image.

2.4. Reference

The SRTM dataset was obtained from http://srtm.csi.cgiar.org/

2.5. What’s next?

Now that we can see our data displayed properly, let’s investigate how we can analyze it further.

© Copyright 2012, Linfiniti Consulting CC.