Mastering Geospatial Development with QGIS 3.x
上QQ阅读APP看书,第一时间看更新

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 same sample raster, Gray_50M_SR_W.tif, which represents shaded relief, hypsography, and flat water for Earth.

Add Gray_50M_SR_W.tif to the QGIS canvas and open its Symbology tab from Layer Properties. As this is a singleband raster, QGIS defaults the Render type value to Singleband gray with the following parameters:

  • Gray band: Band 1 (Gray). This is 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. This is the gradient to apply to the selected gray band. The choices are Black to white and White to black.
  • Min: 56. The minimum cell value found in the gray band.
  • Max: 250. The maximum cell value found in the gray band.
  • Contrast enhancement: Stretch to MinMax. The method that's used to stretch the color gradient to the gray band with respect to the Min and Max values.

These are shown in the following screenshot:

Min / max value settings: This 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 of 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.
  • Statistics Extent: The extent of the raster to sample for cell values. Either the Whole rasterextent of the raster, or the Current or Updated 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 Apply 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 screenshot 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: