Styling singleband rasters

In this section, the three different band render types that are appropriate for singleband rasters will be covered. Singleband rasters can be styled using three different band render types: paletted, singleband gray, and singleband pseudocolor.

Note that even though raster color rendering and resampling are part of raster style properties, they will be discussed separately in later sections as they are common to all singleband and multiband raster renderers.

Tip

The raster band render type should be chosen to best match the type of data. For instance, a palette renderer is best used on rasters that represent discrete data, such as land use classes. The singleband gray would be a good choice for a hillshade, while a singleband pseudocolor would work well on a raster containing global temperature data.

Paletted raster band rendering

The paletted raster band renderer applies a single color to a single raster value. QGIS supports the loading of rasters with paletted colors stored within and the changing of the color assigned to the raster value. QGIS does not currently support the creation of color palettes for singleband rendering. However, existing QGIS layer style files (.qml) that contain palettes can be applied by clicking on the Load Style button in the layer properties.

As an example of a raster with a color palette stored within it, add NA LC 1km.tif from the sample data to the QGIS canvas and open the Style tab under Layer Properties. The following figure shows the Paletted band renderer being applied to Band 1 of the raster:

Paletted raster band rendering

To change a color, double-click on a color in the Color column to open the color picker.

Singleband gray raster band rendering

The singleband gray band renderer stretches a gradient between black and white to a single raster band. Additionally, contrast enhancements are available to adjust the way the gradient is stretched across the raster band's values. Let's apply a singleband gray renderer and a contrast enhancement to the sample GRAY_50M_SR_W.tif raster file that represents shaded relief, hypsography, and flat water for Earth.

Add GRAY_50M_SR_W.tif to the QGIS canvas and open its Style tab from Layer Properties. As this is a singleband raster, QGIS defaults the Render type value to Singleband gray with the following parameters (as shown in the next screenshot):

  • Gray band: Band 1 (Gray) (The raster band that is being styled. If a multiband raster is being used, then the combobox will be populated with all raster bands.)
  • Color gradient: Black to white (The gradient to apply to the selected gray band. The choices are Black to white and White to black)
  • Min: 105 (the minimum cell value found in the gray band)
  • Max: 207 (the maximum cell value found in the gray band)
  • Contrast enhancement: Stretch to MinMax (the method used to stretch the color gradient to the gray band with respect to the Min and Max values)
    Singleband gray raster band rendering

The Min, Max, and Contrast enhancement parameters work together to determine how to stretch the color gradient to the gray band. To understand how these parameters work together, we need to first discuss how the Min and Max values are derived, which draws our attention to the Load min/max values section of the Band rendering options. The Load min/max values section contains parameters that are used to calculate which Min and Max values should be set. Three sets of parameters must be set before you click on the Load button; they are as follows:

  • Cell value selection: Selects cell values to include in the Min and Max value determination. Rasters may have cell values that are outliers, which may affect the rendering of the image. For instance, if only a few cells have an abnormally high value, then the gradient will stretch all the way to these high values, which will cause the raster to look overly gray and bland. To combat this grayness, some cell values can be excluded so that the gradient is not skewed by these outliers. Three methods are available to select cell values, and it is recommended that you experiment with these values to achieve the most desirable selection of cell values:
    • Cumulative count cut: This includes all values between the two parameters. In the preceding screenshot, all values between 2% and 98% of the cell data range were included. In general, this will remove the few very high and very low values that may skew the gradient.
    • Min / max: This includes all values.
    • Mean +/- standard deviation: This includes all values within the specified number of standard deviations about the mean of all values.
  • Extent: The extent of the raster to sample for cell values. Either the Full extent of the raster or the Current canvas extent can be used.
  • Accuracy: This determines the accuracy of the min/max calculation. The calculation can either be an Estimate (faster) or an Actual (slower) option. In general, Actual (slower) is the preferred option; however, for very large rasters, Estimate (faster) may be preferred to save time.

With the Load min/max values set, click on the Load button to calculate the Min and Max values. With the Min and Max values set, we can turn our attention to the Contrast enhancement parameter. The Contrast enhancement parameter sets how to stretch the color gradient across the cell values of the gray band. The following four methods are available for Contrast enhancement:

  • No enhancement: No enhancement is applied. The color gradient is stretched across all values in the entire gray band. While this may be desired sometimes, it may tend to make the raster look overly gray.
  • Stretch to MinMax: This method stretches the color gradient across the gray band between the Min and Max values. It generally produces a higher contrast, a darker rendering than No enhancement. All cell values below the Min value are assigned the lowest gradient color and all cell values above the Max value are assigned the highest gradient color.
  • Stretch and clip to MinMax: This method stretches the color gradient across the gray band between the Min and Max values. It produces the same rendering as the Stretch to MinMax method, except that all cell values below the Min value and all values above the Max value are assigned no color (and they are transparent).
  • Clip to MinMax: This method stretches the color gradient across all values in the gray band, which is the same result as No enhancement, except that all cell values below the Min value and all values above the Max value are assigned no color (and they are transparent).

The following figure shows the effects of the four different Contrast enhancement methods on the Gray_50M_SR_W.tif sample file when the Color gradient field is set to Black to white, Min is set to 107, and Max is set to 207. A Min value of 107 is selected to exclude the cell value of 106 that is associated with the oceans.

Singleband gray raster band rendering

Singleband pseudocolor raster band rendering

The singleband pseudocolor band renderer stretches a color ramp to a single raster band. Additionally, three Color interpolation methods are available to adjust the way the color ramp is stretched across the raster band's values with respect to the min and max cell values (for a discussion on determining min and max values, see the preceding section).

Let's apply a singleband pseudocolor renderer to the GRAY_50M_SR_W.tif sample data raster file that represents shaded relief, hypsography, and flat water for Earth. Add GRAY_50M_SR_W.tif to the QGIS canvas and open its Style tab from Layer Properties. For the Render type field, choose Singleband pseudocolor.

The singleband pseudocolor render type has many interworking parameters that are best explained as a whole through the lens of a workflow, instead of explaining them as separate parts. The example shown in the following screenshot will be the basis for explaining the parameters:

Singleband pseudocolor raster band rendering

Using the preceding image for reference, complete the following steps:

  1. First, the band should be selected. For the Band field, choose Band 1 (Gray). If this were a multiband raster, more bands would be available for selection.
  2. Next, we should choose the color ramp to apply to the raster. As none of the default color ramps are suitable for our example, click on the color ramp combobox to open it, scroll to the bottom, and choose New color ramp (as shown in the following screenshot):
    Singleband pseudocolor raster band rendering
  3. When prompted, choose cpt-city as the color ramp type; then click on OK. This will open the cpt-city color ramp window. In the Topography/bathymetry group, select the wiki-2.0 color ramp and add it. Optionally, the color ramp can be inverted by checking the Invert parameter.

    The color ramp can be applied to the raster cell values in a Continuous or Equal interval classification mode terminating at the Min and Max values:

    • Continuous: This stretches the color ramp between the Min and Max values, with each unique value being assigned a unique color.
    • Equal interval: This assigns a number of colors designated by the Classes parameter across groups of values. For instance, if five classes are specified, then no matter how many unique values exist in the raster, five colors will be applied to the raster; each color will be applied to groups of values with group value ranges of (Max – Min)/Classes.
  4. Set the mode to Continuous, the Min value to 105, and the Max value to 207.
  5. Click on the Classify button to apply the color ramp to the values. The classification list on the left will populate with values, colors, and labels.

    The last step is to choose the Color interpolation method. The following three methods are available and they have a significant effect on how the raster will be rendered:

    • Discrete: Assigns only, and exactly, the colors chosen in the classification list. Values between values listed in the Value column are assigned the color assigned to the next highest listed value. In other words, if there are, say, 164 unique values in the raster and 15 colors listed in the classification list, the raster will be rendered with exactly the 15 listed colors. This method is best for cases where you want to reduce the number of colors that will be used to render the raster.
    • Linear: This assigns a unique color to each unique raster value. Values between values listed in the Value column are assigned a unique color that is calculated linearly and is based on its location between the surrounding listed values. In other words, if there are, say, 164 unique values in the raster and 15 colors listed in the classification list, the raster will be rendered with the 164 unique colors that appear as a nice, linear progression through the 15 listed colors. This method is best for raster data that represents continuous information (for example, elevation or temperature data) where you want a smooth progression of color that is stretched across the raster values.
    • Exact: This assigns a unique color to only the values listed in the Value column of the classification list. In other words, if there are, say, 164 unique values in the raster and 15 colors (and 15 associated values) listed in the classification list, only the 15 raster values that are listed will be rendered with their associated colors. No other values will be assigned a color. This method is best for raster data that represents discrete data classes where you do not want non-listed values to be assigned any color.

      The following figure shows the effects of the three Color interpolation methods on our sample data as configured so far:

    Singleband pseudocolor raster band rendering
  6. Set the Color interpolation field to Linear to assign all unique values a unique color.

    Optionally, you could check Clip (below the classification list); this would not assign colors to values outside the maximum and minimum values listed in the classification list.

  7. Click on Apply or OK to render the raster.

These three singleband render types (paletted, singleband gray, and singleband pseudocolor) provide a large amount of flexibility and customization to fit your styling needs. The next section covers the remaining band render type that is best applied to multiband rasters: multiband color.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset