Video - Introduction to Raster Data (Part 1): Processing and Visualizing Single-Band Rasters

Catalogue number: Catalogue number: 89200005

Issue number: 2020019

Release date: December 1, 2020

QGIS Demo 19

Introduction to Raster Data (Part 1): Processing and Visualizing Single-Band Rasters - Video transcript

(The Statistics Canada symbol and Canada wordmark appear on screen with the title: "Introduction to Raster Data (Part 1): Processing and Visualizing Single-Band Rasters")

So in today's tutorial we'll introduce using raster data in QGIS - specifically focussing on single-band rasters. These rasters depict changes in a single continuous variable, such as precipitation, slope or elevation. One of the most common single-band rasters are Digital Elevation Models or DEMs for short, which show changes in height above sea level. We'll cover some generic raster functions, such as Merge and Reproject; discuss the parameters for their visualization, and then in a follow up demo cover some DEM specific tools and the Raster Calculator. This will provide you with foundational skills for processing, combining and visualizing single-band rasters. Raster datasets epitomize the finer resolution and powerful analyses that are possible with publically available datasets, with resolutions of 15 to 30 metres being common.

As established, for a selection of files in the Browser Panel we can right-click and Add Selected Layers to load them simultaneously in to the Layers Panel. The boundaries between the DEMs are pronounced, resulting in their splotchy appearance. And this is because visualization is tailored to their specific value ranges, which vary significantly due to the mountainous terrain.

To address this we can merge the DEMs into one file, which will create a uniform value range for visualization. In the Processing Toolbox search and open the Merge tool under GDAL - Raster miscellaneous. Click Select All in the Multiple Selection box for the Input Layers. Since we want the full value range to be used in visualization leave the Grab pseudocolour from first layer parameter unchecked. The separate band parameter applies to composite rasters, such as satellite imagery. Since we are using single-band rasters we'll leave it unchecked. NoData values often relate to the cells at the edge of rasters, and may appear as a black perimeter. Here we'll leave the NoData values as default, as well as the compression parameters. So run with a temporary output file, since the merged file is around 1 gigabyte. And the process takes around 6 minutes to complete. If one tool fails there are often alternatives. For example, here we could use r.patch, a GRASS tool, to merge the rasters.

Once complete, the merged file appears like this. The visualization is a marked improvement, with the full value range being used in its rendering.

Now we'll use the Warp (reproject) tool to transform the projection and coordinate reference system. In general, it is best practice to avoid projecting rasters due to potential adverse effects on cell alignments or values but in this case we want to use a projected system for spatial analysis. There are a few additional parameters to specify within the tool. This includes the Source CRS, selecting NAD 83 (CSRS), a geographic coordinate system, from the drop-down. Then we can specify the Target coordinate reference system to transform to, opening the system selector and entering 26911 for NAD83 UTM Zone 11 N, which corresponds with the current location. Change the Resampling method to Bilinear, as Nearest Neighbour is better suited to thematic rasters. Once again we'll leave the NoData values unset, as we'll define them in our output raster. Leave the georeferenced units as-is to use the source layer's resolution. And we'll leave all other parameters with defaults and once again save to a temporary output file. And the tool takes roughly 12 minutes to complete.

As we can see, there were some effects on cell alignment and values, with the warped DEM containing slightly different value ranges. To address this open the Layer Properties box and within the Histogram tab, click Compute Values to assess the distribution of raster data values. Zooming in, based on the distribution, our minimum value is similar to the merged DEM, with 0 being a NoData Value. Clicking on the Hand icon we can interactively select the minimum value in the Histogram, or enter it manually – matching it to the minimum value in the merged DEM: 552. In the Transparency tab, we'll enter 0 as the NoData value to remove the black perimeter around the warped DEM. The min and max values could also be defined in the Symbology tab. So as we can see, the available Layer Properties Box tabs for rasters partly overlap with those of vector datasets. Clicking OK, removing the NoData value and adjusting the minimum has improved the visualization of the warped DEM.

To export a raster to a new dataset we can apply the same procedures applied to vectors. Right-click the raster, Export and click Save as to open the Save Raster Layer As box. We can select the file Format from the drop-down – with GeoTIFF being the most common, and we can optionally create a virtual raster or VRT file. This links the source datasets and applied processes, reducing processing times, file sizes as well as providing other processing advantages. For this format, a subfolder needs to be specified, which will also be the filename. Otherwise, provide an output filename and directory here entering PmBCDEM for projected merged British Columbia digital elevation model.

We can also specify the output cell-size, the source resolution being 15 m by 15 m or 225 square meters per pixel. Finer resolutions result in larger file sizes. So to reduce the total file-size, there is a trade-off, requiring a coarser resolution. Alternatively we can specify the number of rows and columns for the output raster, which will adjust the cell-size accordingly. Here we'll use the source resolution. There are also compression options and a parameter to build pyramids, which we'll cover momentarily with a separate tool. To remove any known NoData values or unrealistic values in the exported raster we could expand and check the NoData values box, click the Plus icon and enter the value range such as -9999 to -1. After clicking OK, the permanent file will be created and added to the Layers Panel.

You may have noticed the longer rendering times for the rasters. This is because the source resolution is being used regardless of the canvas scale. To improve it we can run the output through the Build Pyramids tool, which will create multiple coarser resolution versions of the input, which are then applied for rendering based on the canvas scale. We can then specify the Resampling method and whether the pyramids should be created internally within the DEM file or as an external .ovr file for GeoTiffs. As you can see, clicking Run, this significantly improves rendering times within the Canvas, as we zoom in and out and change the canvas location.

Now let's discuss raster visualization. Once again we'll repeat defining the NoData Value within our permanent raster – entering 0. The data distribution in the Histogram tab is the same as our temporary reprojected file. And finally in the Symbology tab we'll match the minimum value to the merged raster. Clicking apply, the visualization of the DEM now matches that of the temporary merged and reprojected DEMs.

The Symbology tab, as with vector datasets, is used for visualization. The Render type drop-down is equivalent to the Style drop-down, where we can apply different visualization schemes. For the single band rasters - Singleband gray - is the default, but we can also apply Singleband pseudocolour and, specifically for the DEMs, Hillshade. Paletted / Unique is used for thematic rasters and multi-band is used for composite imagery to assign bands to the visible spectrum for analysis and visualization.

There are various Contrast enhancement options in the drop-down. We'll leave it with the default - Stretch to Min/Max. Expanding the Min/Max Value Settings we can specify how the value ranges are applied in rendering. So switch to cumulative count cut. This enhanced the contrast and brightness between cells, using values between the 2nd and 98th percentile. So change the values to 0.5% and 99.5%. And this reduces the contrast, since we are using a larger range of the data – resulting in less values falling outside of the minimum and maximum values. Conversely using a smaller distribution of the total values, entering 5.0% and 95.0%, once again intensifies the contrast and brightness. We could also define the range in standard deviations. So changing it to 5 standard deviations, the contrast and brightness is noticeably reduced. Conversely, using 0.5 has the opposite effect, with more of the DEM values occurring outside of that range. Switch back to Cumulative Count Cut with default values and click Apply.

The Statistics Extent determines the raster values used based on the canvas. By default they apply to the Whole Raster, meaning zooming in or out produces no change in rendering. Alternatively we could switch to the Current extent to optimize visualization for a specific location and scale, or select Updated extent for a dynamic visualization. Now as we change the scale and location of the canvas, the values and visualization of the DEM is adjusted accordingly.

Finally, the Color Rendering drop-down of the symbology tab can be used to fine-tune the visualization. Now let's switch to a Pseudocolour style in the Render type drop-down. Apply the Red-Yellow-Green ramp from the expanded All Ramps side-bar. Reopen the colour ramp, and click Invert Colour Ramp. The particular Interpolation method can be specified as linear, discrete or exact, which varies according to the intended use. We'll leave the other settings as default, clicking Apply and OK. So this is another common visualization for DEMs, with red showing mountain peaks and greens visualizing valley bottoms. Ensure you have a permanent file of the DEM saved which we'll use in the Part II of this demo and then save the project file with a distinctive name.

(The words: "For comments or questions about this video, GIS tools or other Statistics Canada products or services, please contact us:" appear on screen.)

(Canada wordmark appears.)

Date modified: