Adding raster data in context

“Raster data is gridded data with discrete values which forms a matrix of cells or pixels which can be represented in a spatial context”

In simple terms, raster data is a matrix of cells with specific values that are organized into columns and rows.

Each cell in the matrix of data may contain multiple values, each of which is retained in a single band. Bands may be understood, in very simple terms, to function like distinct layers within a raster file. Many aerial imagery rasters, for example, contain a separate band for Red, Green, and Blue (RGB) values. More complex imagery types may contain additional bands, which might be used for storing infrared or hyperspectral information as well. More advanced data formats also support arrays of data overlaid on top of each other, which may be used for storing data such as time-series information.

QGIS supports a wide variety of raster formats by leveraging the Geospatial Data Abstraction Library, or GDAL, to read and write various spatial data formats, and supports over 150 raster data types. Note, however, that although many data format types can be opened within QGIS, writing/ exporting is not supported for all file formats.

Raster data is commonly used as a base map for outlining regional geography for a particular area of interest, as well as for remote sensing and data analysis operations. One of the most common functions of raster data is the capturing of vector data (digitizing) of geographic features from aerial photographs or other raster sources so that the features may be used for spatial analysis.

Depending on the data stored, raster data may be much larger in file size than a vector dataset (depending on the level of detail). Various compression algorithms attempt to facilitate storing raster data with smaller file sizes, but this may be at the cost of performance or data quality, so should be used with care. Raster analysis, however, can be much more performant than similar operations when applied to vector analysis, especially when applied to regions of large extents. Knowing when to choose or convert between raster and vector data sources for analysis operations is a key skill for GIS professionals.

Raster data can be categorized into three broad categories, outlined as follows:

  • Continuous: Phenomena such as spectral data as captured by aerial or satellite imagery systems, temperature measurements, or elevation information
  • Discrete: Also known as thematic data, examples of discrete data may include population density or land-cover information
  • Images: Not to be mistaken for spectral data such as "imagery", images are simply pictures such as scanned maps, drawings, and photographs

You try:

Goal: To explore how to load raster data in QGIS

Exercise 01: Opening raster data from the file browser

  • Navigate to the exercise folder
  • Look at the two raster layers in the folder, taking note of their file extensions. If you do not see the extensions you need to change the folder preferences on your operating system.
  • Try to load a file, such as classified_raster_landcover.asc, by dragging and dropping the data onto the map canvas in the QGIS interface
  • Now try to load the data from QGIS. Click the Open the Data Source Manager button on the Data Source Manager Toolbar, or navigate to the Layers Menu >> Add Layer >> Add Raster Layer
  • Ensure the Raster tab is selected in the Data Source Manager and click the ellipsis menu in the input Raster dataset(s) field
  • Navigate to the exercise folder and select the raster layer people_allow_resampling_true.tif.

Exercise 02: Opening raster data from the QGIS Browser Panel

  • Ensure the QGIS Browser panel is visible.
  • If it is not available, ensure the Browser panel is active from the View >>Panels menu
  • Dock the Browser panel to the QGIS interface if you have not yet done so
  • Use the browser panel to navigate to the exercise folder
  • Expand the raster-data.gpkg in the browser and try to drag the raster-data layer from within the Geopackage and drop it on the map canvas
  • Right-click on the layer people_allow_resampling_true and click add a layer to map canvas.
  • Select the layer classified_raster_landcover and drag it onto the map canvas.

Check your results

How many layers are now visible in your layer list?
Did all of the data loading methods work for you? If not, can you identify what when wrong?
Were you able to identify the different data types in the file browser and the QGIS Browser?
Did you notice how the browser automatically identified suitable data types for you?
Can you identify which files in the exercise folder are raster data files and which are supporting files?

More about raster data in QGIS

The data provided by common GIS Web Services is often raster data, which is often supplied in a tiled format. Raster tiles can be generated by GIS applications and served from a remote source, providing easy access to base map data in an efficient way that only loads the source tiles for the currently viewed extent. XYZ tile services are a common method of providing raster data as a service. These services are supported natively in QGIS, and QGIS additionally includes an XYZ tile service from the OpenStreetMap project by default.

When loading data into QGIS it is important to filter the data based on the extensions. The most common format of raster data is the geographic Tagged Image Format, or geotiff, which have the common file extensions of .tif, .TIFF, or .tiff. Loading layers using the browser panel has significant advantages because it automatically filters for the correct format to be loaded in QGIS. A raster layer may also have auxiliary files that are associated with it. Some of the additional files that may be associated with a raster dataset are outlined in the following table.

File Extension Explanation
.prj A file with projection definition for the layer
.qml QGIS specific file that defines the visual style of the raster data (Symbology)
aux.xml A file with raster statistics
.xml Metadata file describing the characteristics of the raster

Check your knowledge:

  1. Which statement best describes and image taken with a phone camera:

    1. Photographic information
    2. Camera vector data
    3. Raster data that is georeferenced
    4. Raster data that may be geotagged with location and bearing
  2. What is one distinct advantage of adding raster layers using the browser panel:

    1. It is faster than conventional methods using file browsers
    2. It automatically filters the available files to show only items with a suitable extension for loading into QGIS
    3. You can load all the layers that are in the folder and test which one is the correct raster
  3. Can raster layers be stored in a database:

    1. No, Raster layers are sometimes big and cannot fit in a database
    2. Yes, this will enhance analysis as vector and raster operations can be easily combined
    3. Yes, if you purchase a raster driver extension for your database connection