Feature request #782

color ramps for raster layers

Added by perrygeo - over 16 years ago. Updated over 11 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:Symbology
Pull Request or Patch supplied:No Resolution:fixed
Easy fix?:No Copied to github as #:10841

Description

It would be nice to see a selection of color ramps for classifying vectors with graduated symbols. Currently the graduated symbol renderer defaults to a hardcoded red-green color ramp.

Ideally the color ramps should be plugin-able; they should be defined in a simple text file format and read from a directory where users can add their own ramps. There would be two types of ramps that would apply to graduated symbols:

     - discrete colors: the number of steps would have to match totalSteps
     - continuous colors: (eg grass or gmt ramps) would need to code a method
       for determining an RGB color for any point along the continuum

In order to facilitate this, I've attached a simple patch for qgsgraduatedsymboldialog which moves the color selection process into it's own function - getColorFromRamp( rampname, step, totalSteps)

qgis_gradsymbol.diff Magnifier - moves graduated symbol color selection into it's own function for future ramps (3.08 KB) perrygeo -, 2007-10-21 03:55 PM

gradsymbol_ramps_20071027.diff Magnifier - Proof-of-concept patch for graduated symbol color ramps using .cpt files (12 KB) perrygeo -, 2007-10-27 03:29 PM

gradsymbol_ramps_20071028.diff Magnifier - same thing as previous attachment but uses a combo box UI (12.3 KB) perrygeo -, 2007-11-21 09:56 AM

History

#1 Updated by perrygeo - over 16 years ago

I've come up with 4 general types of color ramps

1) Continuous ramps, defined by hard values:
< 0.1 is blue , > 5000 is white

2) Continuous ramps, defined by percentages:
0% is red, 50% is white, 100% is blue

3) Discrete ramps, showing trends:
X number of colors defined which show a numerical trend (ie the order of colors is significant). A good example would be the sequential and diverging color schemes from Color Brewer (http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_intro.html).

4) Discrete ramps, showing unique values:
X number of colors defined which show unique values (ie the order of colors is NOT significant). A good example would be the qualitative color schemes from Color Brewer.


So for each of the classification methods available in qgis we would have to identify which would be appropriate.

A) Graduated Symbol:
#3905 won't really work since the class breaks won't necessarily line up with those defined in the ramps. #3906 would work assuming there is an easily implementable algorithm for finding any color along the continuum. #3907 and #3908 are ideal but would need to ensure that the number of classes matched the number of discrete steps in the ramps.

B) Continuous Value"
Only #3905 and #3906 could be made to work.

C) Unique value:
#3908 would be best but there's no reason why #3907 could not work as well. #3905 and #3906 would not work since the variable of interest is not necessarily numeric.


The remaining questions are:

- what file format works to define the color ramps? have to allow for all 4 of the above types. As much as possible, leverage existing formats like gmt and grass color ramps.

- how do the ramps get "registered" with qgis so that they can be made available to the user?

- how do they get integrated with the UI? preferably a dropdown list of color ramps with a small representative image of the ramp itself.

- how to we implement the algorithm to determine the rgb color for ramps of type #3905 and #3906?

#2 Updated by perrygeo - over 16 years ago

Looking over some color ramp formats, it looks like the GMT .cpt format is the most flexible and allows you to define either continuous or discrete RGB ramps across any range of z-values. Since there is no easy quick flag to specify a discrete vs continuous color ramp in the cpt file itself, the easiest way to differentiate may be to store them in separate folders within a main color ramp directory.

prefix/share/qgis/ramps/discrete
prefix/share/qgis/ramps/continuous

There are a slew of good ramps available as .cpt from http://sview01.wiredworkplace.net/pub/cpt-city/

#3 Updated by perrygeo - over 16 years ago

Proof-of-concept patch for graduated symbol ramps using .cpt files.

Download http://sview01.wiredworkplace.net/pub/cpt-city/cb/div/RdBu_11.cpt and move to ${prefix}/share/qgis/ramps/red_white_blue.cpt

Apply patch (gradsymbol_ramps_20071027.diff), fire up qgis, add a vector layer and test with graduated symbol rendering. If you have any other cpt files in your ramps directory, you have to just type out the file prefix (a comboBox would be a nice enhancement).

Warning: patch needs to be reviewed by someone with more C++ knowledge than myself; it works but may not be optimal or elegant code!

#4 Updated by Marco Hugentobler over 15 years ago

As this patch seems to be in the proof-of-concept patch, I'm moving it further to target 1.0.1

#5 Updated by Marco Hugentobler over 15 years ago

Sorry, typo. I meant proof-of-concept stage.

#6 Updated by Paolo Cavallini about 15 years ago

I agree that using colorbrewer www.colorbrewer.org (as it happens eg in R: http://cran.r-project.org/web/packages/RColorBrewer/RColorBrewer.pdf) would be very useful

#7 Updated by Giovanni Manghi over 14 years ago

The new address of the cpt-city site seems now to be this

http://soliton.vm.bytemark.co.uk/pub/cpt-city/

By the way, what is the status of implementing color ramps in qgis? We miss really just a few things, and one of them is color ramps for vector/raster symbology.

#8 Updated by alobo - over 14 years ago

Please note the important point of having a colorbar
indicating the meaning of the colors. Not sure if this sugggestion
should be
an independent ticket on its own.
Also, perhaps the title of the ticket is misleading, as it
should apply to both vector and raster layers.

Agus

#9 Updated by Giovanni Manghi over 14 years ago

ramps for vectors are now available in the new symbology. Seems that the possibility to import cpt ramps will be available somewhere in the future.

Still missing ramps for rasters, at least I think it would be nice to implement in the actual qgis raster symbology the ramps available in GRASS

http://soliton.vm.bytemark.co.uk/pub/cpt-city/grass/index.html

#10 Updated by Giovanni Manghi almost 14 years ago

There is a new python plugin (it is in the contributed repositories) that allow now to change between a fair large number of colormaps for 1 band rasters. The plugin it is in its early stages of developement nevertheless it maybe a good start to try fill this old void in QGIS base tools.

#11 Updated by Giovanni Manghi over 13 years ago

The "1-banded raster color table" plugin is improving but if someone is able to step in and help the developer it would be nice, as it would be close this 3 years old ticket :)

#12 Updated by Giovanni Manghi over 13 years ago

The plugin improved REALLY MUCH, thanks Benoit.

I really hope that someone can step in and help because this would really fit well into core to fit this big "hole" that qgis has since... always.

cheers!

#13 Updated by Markus Neteler over 13 years ago

See also #3127

#14 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#15 Updated by Giovanni Manghi about 12 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

#16 Updated by Giovanni Manghi over 11 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed
  • Pull Request or Patch supplied set to No

The work to add the color ramps for rasters is ongoing but I think we can definitely close this ticket. A lot of color ramps (the ones available for vectors plus the ones available on CPT CITY, including the GRASS ones) for rasters have been added in QGIS master and is possible already to use them.

Also available in: Atom PDF