Ticket #782 (new patch)

Opened 7 years ago

Last modified 4 years ago

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
Platform Version: Platform: All
Must Fix for Release: No 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

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

Change History

Changed 7 years ago by perrygeo

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

Changed 7 years ago by perrygeo

  • cc perrygeo@… added
  • type changed from defect to enhancement

Changed 7 years ago by perrygeo

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?

Changed 7 years ago by mhugent

  • owner changed from nobody to mhugent

Changed 7 years ago by perrygeo

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/

Changed 7 years ago by perrygeo

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!

Changed 7 years ago by perrygeo

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

Changed 7 years ago by perrygeo

same thing as previous attachment but uses a combo box UI

Changed 6 years ago by jef

  • type changed from enhancement to patch

Changed 6 years ago by mhugent

  • milestone changed from Version 1.0.0 to Version 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

Changed 6 years ago by mhugent

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

Changed 5 years ago by pcav

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

Changed 5 years ago by pcav

  • platform changed from Debian to All

Changed 5 years ago by neteler

  • cc neteler added

Changed 5 years ago by lutra

  • milestone changed from Version 1.0.3 to Version 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.

Changed 5 years ago by alobo

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

Changed 5 years ago by alobo

  • summary changed from color ramps for vector graduated symbols to color ramps for vector graduated symbols and raster layers (pseudocolor and classified)

Changed 5 years ago by lutra

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

Changed 4 years ago by pcav

  • milestone changed from Version 1.5.0 to Version 1.6.0

Changed 4 years ago by lutra

  • summary changed from color ramps for vector graduated symbols and raster layers (pseudocolor and classified) to 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.

Changed 4 years ago by lutra

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 :)

Changed 4 years ago by lutra

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!

Changed 4 years ago by neteler

See also #3127

Note: See TracTickets for help on using tickets.