Working with Raster Data

This Section describes how to visualize and set raster layer properties. QGIS uses the GDAL library to read and write raster data formats GRASS raster support is supplied by a native QGIS data provider plugin. [1] , including Arc/Info Binary Grid .. index:: Arc/Info Binary Grid , Arc/Info ASCII Grid .. index:: Arc/Info ASCII Grid , GeoTIFF .. index:: GeoTIFF , Erdas Imagine .. index:: Erdas Img. and many more.

At the date of this document, more than 100 raster formats are supported by the GDAL library FIXMEcite{GDALweb}. A complete list is available at

Note Not all of the listed formats may work in QGIS for various reasons. For example, some require external commercial libraries or the GDAL installation of your OS was not built to support the format you want to use. Only those formats that have been well tested will appear in the list of file types when loading a raster into QGIS. Other untested formats can be loaded by selecting ..

Working with GRASS raster data is described in Section sec:grass.

What is raster data?

Raster data in GIS are matrices of discrete cells that represent features on, above or below the earth’s surface. Each cell in the raster grid is the same size, and cells are usually rectangular (in QGIS they will always be rectangular). Typical raster datasets include remote sensing data such as aerial photography or satellite imagery and modelled data such as an elevation matrix.

Unlike vector data, raster data typically do not have an associated database record for each cell. They are geocoded by its pixel resolution and the x/y coordinate of a corner pixel of the raster layer. This allows QGIS to position the data correctly in the map canvas.

QGIS makes use of georeference information inside the raster layer (e.g. GeoTiff) or in an appropriate world file to properly display the data.

Loading raster data in QGIS

Raster layers are loaded either by clicking on the mActionAddRasterLayer Load Raster icon or by selecting the View –> mActionAddRasterLayer Add Raster Layer menu option. More than one layer can be loaded at the same time by holding down the Control or Shift key and clicking on multiple items in the dialog Open a GDAL Supported Raster Data Source. .. index:: raster layers!loading

Once a raster layer is loaded in the map legend you can click on the layer name with the right mouse button to select and activate layer specific features or to open a dialog to set raster properties for the layer.

Right mouse button menu for raster layers

  • Zoom to layer extent
  • Zoom to best scale (100%)
  • Show in overview
  • Remove
  • Set layer CRS
  • Set project CRS from layer
  • Properties
  • Rename
  • Add Group
  • Expand all
  • Collapse all

Raster Properties Dialog

To view and set the properties for a raster layer, double click on the layer name in the map legend or right click on the layer name and choose Properties from the context menu: .. index:: raster layers!context menu Figure fig:raster_properties shows the Raster Layer Properties dialog. There are several tabs on the dialog:

  • tab Style
  • tab Transparency
  • tab Colormap
  • tab General
  • tab Metadata
  • tab Pyramids
  • tab Histogram

QGIS can render raster layers in two different way: .. index:: raster layers!supported channels

  • Single band - one band of the image will be rendered as gray or in pseudocolor or a freak out.
  • Three band color - three bands from the image will be rendered, each band representing the red, green or blue component that will be used to create a color image.

Within both render types you can invert the color output using the checkbox Invert color map checkbox.

Single Band Rendering

This selection offers you two possibilites to choose. At first you can select which band you like to use for rendering (if the dataset has more than one band).

The second option offers a selection of available colortables for rendering.

The following settings are available through the dropdownbox selectstring color map Grayscale, where grayscale is the default setting. Also available are

  • Pseudocolor
  • Freak Out
  • Colormap

When selecting the entry selectstring Colormap, the tab tab Colormap becomes available. See more on that at chapter label_colormaptab.

QGIS can restrict the data displayed to only show cells whose values are within a given number of standard deviations of the mean for the layer. .. index:: raster layers!standard deviation This is useful when you have one or two cells with abnormally high values in a raster grid that are having a negative impact on the rendering of the raster. This option is only available for pseudocolor and freak out images.

Three band color

This selection offers you a wide range of options to modify the appearance of your rasterlayer. For example you could switch color-bands from the standard RGB-order to something else.

Also scaling of colors are available.


Viewing a Single Band of a Multiband Raster If you want to view a single band (for example Red) of a multiband image, you might think you would set the Green and Blue bands to ``Not Set’‘. But this is not the correct way. To display the Red band, set the image type to grayscale, then select Red as the band to use for Gray.

Transparency Tab

QGIS has the ability to display each raster layer at varying transparency levels. .. index:: raster layers!transparency Use the transparency slider to indicate to what extent the underlying layers (if any) should be visible though the current raster layer. This is very useful, if you like to overlay more than one rasterlayer, e.g. a shaded relief-map overlayed by a classified rastermap. This will make the look of the map more three dimensional.

Additionally you can enter a rastervalue, which should be treated as NODATA. This can be done manually or with the |mActionContextHelp| Add values from display icon.

An even more flexible way to customize the transparency can be done in the Custom transparency options section. The transparency of every pixel can be set in this tab.

As an example we want to set the water of our example rasterfile landcover.tif to a transparency of 20 %. The following steps are neccessary:

  1. Load the rasterfile landcover.
  2. Open the Properties dialog by double-clicking on the raster filename in the legend or by right-clicking and choosing Properties from the popup menu.
  3. Select the tab Transparency tab
  4. Click the |mActionNewAttribute| Add values manually button. A new row will appear in the pixel-list.
  5. Enter the raster-value (we use 0 here) and adjust the transparency to 20 %.
  6. Press the Apply button and have a look at the map.

You can repeat the steps enum:add and enum:transp to adjust more values with custom transparency.

As you can see this is quite easy to set custom transparency, but it can be quite a lot of work. Therefore you can use the button |mActionFileSave| Export to file to save your transparency-list to a file. The button |mActionFolder| Import from file loads your transparency-settings and applies them to the current rasterlayer.


The tab Colormap tab is only available, when you have selected a single-band-rendering within the tab Style tab (see chapt. label_sombology).

Three ways of color interpolation are available:

  • Discrete
  • Linear
  • Exact

The button Add Entry adds a color to the individual color-table. Delete Entry deletes a color from the individual color-table and the Sort sorts the color table according to the pixel values in the value column. Double-Clicking on the value-column lets you insert a specific value. Double clicking on the color-column opens the dialog Select color where you can select a color to apply on that value. Further you can also add labels for each color but this value won’t be displayed when you use the identify feature tool.

Alternatively you can click on the button |mActionNewAttribute| Load colormap from Band, which tries to load the table from the band (if it has any).

The block Generate new color map allows you to create newly categorized colormaps. You only need to select the selectnumber number of classes 15 and press the button Classify. Currently only one selectstring Classification mode Equal Interval is supported .. index:: raster layer!classify.

..index:: label_generaltab

General Tab

The tab General tab displays basic information about the selected raster, including the layer source and display name in the legend (which can be modified). This tab also shows a thumbnail of the layer, its legend symbol, and the palette.

Additionally scale-dependent visability can be set in this tab. You need to check the checkbox and set an appropriate scale where your data will be displayed in the map canvas.

Also the coordinate reference system (CRS) is printed here as a PROJ.4-string. This can be modified by hitting the Specify button.

Metadata Tab

The tab Metadata tab displays a wealth of information about the raster layer, including statistics about each band in the current raster layer. Statistics are gathered on a ‘need to know’ basis, so it may well be that a given layers statistics have not yet been collected.

This tab is mainly for information. You cannot change any values printed inside this tab. To update the statistics you need to change to tab tab Histogram and press the button Refresh on the bottom right, (see ch. label_histogram.

Pyramids Tab

Large resolution raster layers can slow navigation in QGIS. By creating lower resolution copies of the data (pyramids), performance can be considerably improved as QGIS selects the most suitable resolution to use depending on the level of zoom. .. index:: raster layers!pyramids .. index:: raster layers!resolution pyramids

You must have write access in the directory where the original data is stored to build pyramids.

Several resampling methods can be used to calculate the pyramids:

  • Average
  • Nearest Neighbour

When checking the checkbox checkbox Build pyramids internally if possible QGIS tries to build pyramids internally.

Please note that building pyramids may alter the original data file and once created they cannot be removed. If you wish to preserve a ‘non-pyramided’ version of your raster, make a backup copy prior to building pyramids.

Histogram Tab

The tab Histogram tab allows you to view the distribution .. index:: raster layers!histogram of the bands or colors in your raster. It is generated automaticaly when you open tab Histogram tab. You can choose which bands to display by selecting them in the list box at the bottom left of the tab.


Gathering Raster Statistics

To gather statistics for a layer, select pseudocolor rendering and click the Apply button. Gathering statistics for a layer can be time consuming. Please be patient while QGIS examines your data!

Raster Calculator

The Raster Calculator in the Layer menu allows to perform calculations on basis of existing raster pixel values. The results are written to a new raster layer with a GDAL supported format.

The Fields list contains all loaded raster layers that can be used. To add a raster to the raster calculator expression field, double click its name in the Fields list. You can then use the operators to construct calculation expressions or you can just type it into the box.

In the Result layer section you have to define an output layer. You can then define the extent of the calculation area based on an input raster layer or based on X,Y coordinates and on Columns and Rows to set the resolution of the output layer. If the input layer has a different resolution, the values will be resampled with nearest neighbor algorithm.

The Operators section contains all usable operators. To add an operator to the raster calculator expression box, click the appropriate button. Mathematical calculations ( + , - , * , ... ) and trigonometric functions ( sin, cos, tan, ... ) are available. Stay tuned for more operators to come!

With the checkbox Result to project checkbox the result layer will automatically added to the legend area and can be visualized.

Raster Analysis

Apart from the raster calculator, additional raster analysis in QGIS 1.7 is provided by the GDALTools core plugin. Please refer to section GDAL Tools Plugin for more information.

[1]GRASS raster support is supplied by a native QGIS data provider plugin.
© Copyright 2012, QGIS project.