Opened 16 years ago

Last modified 13 years ago

#782 new patch

color ramps for raster layers

Reported by: perrygeo Owned by: mhugent
Priority: minor: annoyance Milestone: Version 1.7.0
Component: Symbology Version: Trunk
Keywords: symbology color ramp Cc: perrygeo@…, neteler
Must Fix for Release: No Platform: All
Platform Version: Awaiting user input: yes

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)

Attachments (3)

qgis_gradsymbol.diff (3.1 KB ) - added by perrygeo 16 years ago.
moves graduated symbol color selection into it's own function for future ramps
gradsymbol_ramps_20071027.diff (12.0 KB ) - added by perrygeo 16 years ago.
Proof-of-concept patch for graduated symbol color ramps using .cpt files
gradsymbol_ramps_20071028.diff (12.3 KB ) - added by perrygeo 16 years ago.
same thing as previous attachment but uses a combo box UI

Download all attachments as: .zip

Change History (23)

by perrygeo, 16 years ago

Attachment: qgis_gradsymbol.diff added

moves graduated symbol color selection into it's own function for future ramps

comment:1 by perrygeo, 16 years ago

Cc: perrygeo@… added
Type: defectenhancement

comment:2 by perrygeo, 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:

#1 won't really work since the class breaks won't necessarily line up with those defined in the ramps. #2 would work assuming there is an easily implementable algorithm for finding any color along the continuum. #3 and #4 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 #1 and #2 could be made to work.

C) Unique value:

#4 would be best but there's no reason why #3 could not work as well. #1 and #2 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 #1 and #2?

comment:3 by mhugent, 16 years ago

Owner: changed from nobody to mhugent

comment:4 by perrygeo, 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/

comment:5 by perrygeo, 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!

by perrygeo, 16 years ago

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

by perrygeo, 16 years ago

same thing as previous attachment but uses a combo box UI

comment:6 by jef, 16 years ago

Type: enhancementpatch

comment:7 by mhugent, 15 years ago

Milestone: Version 1.0.0Version 1.0.1

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

comment:8 by mhugent, 15 years ago

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

comment:9 by pcav, 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

comment:10 by pcav, 15 years ago

Platform: DebianAll

comment:11 by neteler, 15 years ago

Cc: neteler added

comment:12 by lutra, 15 years ago

Milestone: Version 1.0.3Version 1.2.0

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.

comment:13 by alobo, 15 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

comment:14 by alobo, 15 years ago

Summary: color ramps for vector graduated symbolscolor ramps for vector graduated symbols and raster layers (pseudocolor and classified)

comment:15 by lutra, 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

comment:16 by pcav, 14 years ago

Milestone: Version 1.5.0Version 1.6.0

comment:17 by lutra, 14 years ago

Summary: color ramps for vector graduated symbols and raster layers (pseudocolor and classified)color ramps for raster layers

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.

comment:18 by lutra, 14 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 :)

comment:19 by lutra, 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!

comment:20 by neteler, 13 years ago

See also #3127

Note: See TracTickets for help on using tickets.