QGIS:Becoming a GIS Power User
上QQ阅读APP看书,第一时间看更新

Styling raster layers

After this introduction to data sources, we can create our first map. We will build the map from the bottom up by first loading some background rasters (hillshade and land cover), which we will then overlay with point, line, and polygon layers.

Let's start by loading a land cover and a hillshade from landcover.img and SR_50M_alaska_nad.tif, and then opening the Style section in the layer properties (by going to Layer | Properties or double-clicking on the layer name). QGIS automatically tries to pick a reasonable default render type for both raster layers. Besides these defaults, the following style options are available for raster layers:

  • Multiband color: This style is used if the raster has several bands. This is usually the case with satellite images with multiple bands.
  • Paletted: This style is used if a single-band raster comes with an indexed palette.
  • Singleband gray: If a raster has neither multiple bands nor an indexed palette (this is the case with, for example, elevation model rasters or hillshade rasters), it will be rendered using this style.
  • Singleband pseudocolor: Instead of being limited to gray, this style allows us to render a raster band using a color map of our choice.

The SR_50M_alaska_nad.tif hillshade raster is loaded with Singleband gray Render type, as you can see in the following screenshot. If we want to render the hillshade raster in color instead of grayscale, we can change Render type to Singleband pseudocolor. In the pseudocolor mode, we can create color maps either manually or by selecting one of the premade color ramps. However, let's stick to Singleband gray for the hillshade for now.

The Singleband gray renderer offers a Black to white Color gradient as well as a White to black gradient. When we use the Black to white gradient, the minimum value (specified in Min) will be drawn black and the maximum value (specified in Max) will be drawn in white, with all the values in between in shades of gray. You can specify these minimum and maximum values manually or use the Load min/max values interface to let QGIS compute the values.

Tip

Note that QGIS offers different options for computing the values from either the complete raster (Full Extent) or only the currently visible part of the raster (Current Extent). A common source of confusion is the Estimate (faster) option, which can result in different values than those documented elsewhere, for example, in the raster's metadata. The obvious advantage of this option is that it is faster to compute, so use it carefully!

Below the color settings, we find a section with more advanced options that control the raster Resampling, Brightness, Contrast, Saturation, and Hue—options that you probably know from image processing software. By default, resampling is set to the fast Nearest neighbour option. To get nicer and smoother results, we can change to the Bilinear or Cubic method.

Click on OK or Apply to confirm. In both cases, the map will be redrawn using the new layer style. If you click on Apply, the Layer Properties dialog stays open, and you can continue to fine-tune the layer style. If you click on OK, the Layer Properties dialog is closed.

The landcover.img raster is a good example of a paletted raster. Each cell value is mapped to a specific color. To change a color, we can simply double-click on the Color preview and a color picker will open. The style section of a paletted raster looks like what is shown in the following screenshot:

If we want to combine hillshade and land cover into one aesthetically pleasing background, we can use a combination of Blending mode and layer Transparency. Blending modes are another feature commonly found in image processing software. The main advantage of blending modes over transparency is that we can avoid the usually dull, low-contrast look that results from combining rasters using transparency alone. If you haven't had any experience with blending, take some time to try the different effects. For this example, I used the Darken blending mode, as highlighted in the previous screenshot, together with a global layer transparency of 50 %, as shown in the following screenshot: