Colour Scale Bar for One-Band Rasters    
V0.5.0 - 11 March 2012

This QGIS plugin creates a colour scale bar image file (png) for a coloured 1-band raster. Does not work for QGIS native colour schemes.Use the created colour scale bar as legend in print composer.

Distributed under the GPL licence
 

Once installed the bccscbar plugin can be found in the 'Raster/Raster Colours' menu.

 


Main window

--- How to use this app ---

  1. Select a QGIS .qml file containing a saved colour palette The colour palette must be of type: INTERPOLATION:DISCRETE.
    Alternatively select a colour palette generated with '1-band raster colour table'
  2. Fill in the relevant info:
    At minimum you have to define the aspect of the final colour scale bar: either vertical or horizontal.
  3. From V0.4.0, you can click on the 'Sel out dir...' button to select an output folder to save the colour scale bar image file to. By default, the image is saved in the same folder as the palette file.
  4. Click 'Create' to create the colour scale bar image file. The file is located in the same folder as the input file.
  5. Open your favorite image viewer and point it to the file returned by the plugin.
  6. Tweak the parameters and run again until the time you are satisfied with your colour scale bar.
  7. Use the created colour scale bar as legend in print composer.

Guided tour:
 
Main window

On completion, the plugin returns the name of the created colour scale bar:

name of the created colour scale bar

NOTES
  • Results are not guaranteed. You will perhaps need to tweak the parameters in order to get acceptable results!
  • The title can contains more than one line. Separate each line with '\\n'.
  • The units text can only be one line. An extra lines are ignored.
  • The colour table files (*.txt or *.qml) do not contain information about the minimum value. If needed, you will have to enter it in the 'Minimum' textbox.
  • The 'enforce'checkbox is to force the decimal places to be that number, padding with trailing 0s if necessary.
  • The resolution of the colour scale bar image is 72 dpi.
     
  • The application can be run stand-alone, with no QGIS. Please see the file standalone.py for more information. You still need to have Python and Qt installed on your machine in order to use the standalone version. but for a quick and dirty go at the app it could be better that launching QGIS to run the plugin.

Examples:

Example: vertical scale bar     A vertical scale bar.
 
Parameters:
 
Title = SRTM
Units = m [AMSL]
 
Enforce decimals = False
Number of decimals = N/A
 
Font size = 10
 
Automatic tick = True
  number of Ticks = N/A
 
box Width = 50
box Height = 2
 
Annotate Extrema = False
minimum value = N/A

A horizontal scale bar (click for full scale version)

Example: horizontal scale bar

Parameters:

Title = SRTM
Units = m [AMSL]
 
Enforce decimals = True
Number of decimals = 1
 
Font size = 10
 
Automatic tick = True
  number of Ticks = N/A
 
box Width = 5
box Height = 20
 
Annotate Extrema = False
minimum value = N/A

Return to BC-Consulting plugins page.

Please report any bug/problem/wish to the QGIS User mailing list [mailto: qgis - user at lists dot osgeo dot org].


History

  • 0.5.1: Contribution from Thomas Wahlmüller.
        A summary of the changes:
        discrete styles
        ==========
        same as before, no code changed
        only function name renamed, to better distingunish between the
        functions of other annotations
       
        interpolated
        ========
        interpolation is done in "cdlgSCBR.py"
        annotion is different to discrete (at least 2 ticks at minimum and
        maximum, more ticks are spread equaly)
       
        exact
        ====
        annotation is in the middle of the color, also the height/width of
        the bar is set according to annotation
        a border is drawn around every element
        horizontal bar: minimum box width is maximum annotation length
        vertical bar: minimum box height is annotation height
    Thanks Thomas!
  • 0.4.1: Title font is now linked to the selected label font.
  • 0.4.0: Add the 'Select output folder' button. Remember the last folder used for output and the last folder used for palette selection.
  • 0.3.1: Correct visual interface glitches on Ubuntu.
  • 0.3.0: Changed button text from (*.tbl) to (*.txt) and removed 'pressed' signal trapping.
  • 0.2.0: Changed deprecated call to current call in plugin initialisation.
  • 0.1.0: Correct a bug preventing plugin removal from the plugin menu.
  • 0.0.1: Original published.