Request for comment 1: Raster Refactor

Date 20 June 2007
Tim Sutton
Contact tim at
Status announced/accepted/refused



The raster related code in QGIS needs an overhaul. The current implementation is monolithic with all functionality in just a few 'everything but the kitchen sink' classes. We propose to overhaul this, in particularly QgsRasterLayer. Currently we dont have a proper provider model - QgsRasterLayer has embedded logic specific to GDAL and the WMS implementation although implemented as a provider was achieved by using provider specific if/then statements throughout the code. Also aspects such as colour rendering use hardcoded rendering loops based on ENUMs which makes it difficult for people to contribute new rendering types. Other ares that need to be hived off are histogram generation, pyramid generation, legend generation, transparency handling, classification and statistics gathering. Another area needing attention is the serialisation and deserialisation of statistics so that after the initial use of a raster, stats do not need to be recomputed. The primary goals of the overhaul will thus be to:

  • provider a better provider based implementation including QgsRasterLayer becoming an abstract base class with distinct providers for WMS, GDAL etc.
  • create a separate class for transparency management
  • create a separate implementation for inline filtering of raster data. This will allow for example us to render to screen an RGB value computed from all 7 bands on a Landsat TM image. Another application of filters will be on the fly smoothing etc using kernel operations.
  • create a separate implementation for pixel shading. This will allow different pixel classifiers to be written in a plug-in manner, opening up QGIS raster implementation to a much greater range of visualisation options.
  • create a separate implementation for overview / pyramid building (this is somewhat provider specific).
  • create a separate implementation for raster stats (perhaps this should be part of the provider) with a better fleshed out QgsRasterStats class. (Currently we have only QgsRasterBandStats).
  • create a better implementation for legend and thumbnail creation, so that we can e.g. show a thumbnail in the legend and a proper legend for pixel color classifications similar to that provided in the QGIS vector implementations.
  • provide a framework for off-screen rendering and caching so that pan operations can be optimised. (?)
  • provide raster write facilities.

I have illustrated some of these concepts in the attached UML diagram.

(requires the open source ArgoUML application to open)


Questions that appeared in previous discussions (e.g. on developers mailing list)

Voting History

Your Name
* + 1*
colspan="3" align="center" comments


Rasterrefactoruml.jpg (161 KB) Redmine Admin, 2011-11-23 04:44 PM