Thus far we’ve worked mostly with vector data, which consists of features, and these features are themselves made up of points and lines. In this chapter we will learn about raster data. Remember when you were editing OpenStreetMap in JOSM? The points, lines and shapes that you drew were vector data. But when you loaded Bing aerial imagery in the background, that was raster data. So what’s the difference?
Raster data essentially comes in the form of an image. It is made up of pixels, like a photograph, and a raster image will always be some number of pixels wide and some number of pixels high. If you zoom in far enough on a raster image, it will start to become blurry, just as if you opened a photo on your computer and zoomed in very close. As we’ll see in this chapter, however, a raster image can mean more than just a photograph from the sky. Follow along and we’ll learn all about rasters!
Not all raster data consist of aerial photographs. There are many other forms of raster data, and in many of those cases, it’s essential to symbolise the data so that it becomes properly visible and useful. In this section we’ll add a new kind of raster and see how to change its symbology.
High resolution, contemporary data on human population distributions are a prerequisite for the accurate measurement of the impacts of population growth, for monitoring changes and for planning Interventions. The AsiaPop project was initiated in July 2011 with an aim of producing detailed and Freely-available population distribution maps for the whole of Asia.*
When it loads, you’ll notice that the new raster image appears as whole Indonesia’s Islands in grey colour.
The layer appears grey (and doesn’t give us any information) because its symbology hasn’t been customised yet. In the colour aerial photograph we loaded via OpenLayer Plugin, everything is already deﬁned. But if you load a raster image and it’s just a grey rectangle, then you know there’s no symbology for it yet. It still needs to be deﬁned. That’s what we will do next.
Good! This tell us that there is data in this layer. And by looking at it we can get an idea in Java Island, population number higher than other island in Indonesia.
Let’s stop for a minute and understand what is happening here. Remember that an image is made up of pixels, individual cells that contain a value, which is usually a colour value. For example, if you zoom in very closely on a photograph you can see those individual pixels, like this:
The value of each cell is saved in the ﬁle. Imagine the ﬁle being saved something like this, where each square is a pixel:
Of course the computer doesn’t understand words for colours. In fact the value of each cell would be a number, which the computer then associates with a certain colour. For our aerial image, this is already deﬁned. Since it is a normal image, it knows to associate the numbers for each pixel in the ﬁle with the common colours that we see every day. But this new raster image is different, because the values of each pixel don’t represent colours, but rather altitude, and QGIS doesn’t know automatically how to display it. Hence it shows every pixel in the image as grey, even if the values in each pixel are different. When we change the symbology to Psuedocolor, we can see all the different pixel values shown with various colours.
It would be nice to represent our Indonesian Population layer as a greyscale spectrum, rather than a variety of bright colours. Next we will tell QGIS to symbolise the layer with colours in a spectrum, beginning at the lowest pixel value in the ﬁle and ending at the highest pixel value. In other words, if the pixel values looked like this:
QGIS would create a spectrum equating numbers to colours like this:
And render the image like this:
To do that, let’s start to symbolise Indonesia Population:
Notice how the custom Min and Max values have changed. The lowest pixel value in this image ﬁle is 0 and the highest is about 3024.93. But what are the minimum and maximum values that should be used? The current values are those that just gave us a grey rectangle. Instead, we should be using the minimum and maximum pixel values that are actually in the image. You can determine those values easily by loading the minimum and maximum values of the raster.
We’ve learned to do this the tricky way, but can we do it faster? Of course! 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 more easily.
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.
Certain types of rasters allow you to gain more insight into the terrain that they represent. Digital Elevation Models (DEMs) are particularly useful in this regard. In this section we’ll do a little bit more with our DEM raster, in order to try to extract more information from it.
The DEM you have on your map right now does show you the elevation of the terrain, but it can sometimes seem a little abstract. It contains all the 3D elevation information about the terrain that you need, but it doesn’t really look 3-Dimensional. To get a better look at 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 work with DEMs, we will use the all-in-one DEM (Terrain models) analysis tool.
There should now be a new layer called hillshade that looks like this:
This looks more Three-Dimensional, but can we improve on this? When you open DEM (Terrain Models) tools, you will notice in the Mode Options for hillshade there’re Azimuth of the light and Altitude of the light.
Azimuth of the light defines in which direction the sun is, whereas 0° represent north, east is 90°, south is 180° and west is 270°. While Altitude of the light is the angle between the horizon and the centre of the sun’s disc.
On its own, the hillshade looks like a plaster cast. It will look better if we can combine it with our more colourful DEM. We can do this by making the hillshade layer an overlay.
Hillshade can provide very useful information about the sunlight at a given time of day. But it 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.
Using a hillshade in this way, it’s possible to enhance the topography of the landscape. If the effect doesn’t seem strong enough to you, you can change the transparency of the hillshade layer; but of course, the brighter the hillshade becomes, the dimmer the colours behind it will be. You will need to ﬁnd a balance that works for you.