[GIS] Using color ramps (cpt examples and wikicarto 2.0) in QGIS 2.4

color rampqgis-2.4style

I´ve been trying to use some of the color ramps you can find at cpt-city but I have problems with the value ranges (right word?) for each color when loading them. I just don´t understand how to get the settings in the Style window right so the desired colors appear as the authors intended.

I´ll give an example to show my problem:

I created the colorscheme “Wikicarto 2.0” as a qml-file by putting the example code into a texteditor and saving as .qml as suggested here:
http://en.wikipedia.org/wiki/Wikipedia:Graphics_Lab/Resources/QGIS/Create_a_topographic_background#Existing_Wikipedia_color_palettes

Now if I load this qml as my style in the properties window of my DEM everything looks fine, especially the Values used for each color. 🙂

Correct values as intended by author

If I change settings in the part where it says “Generate new color ramp” or “Load Min/Max values” it only throws everything out of order, the values for the colors change and I don´t know what I would have to change in these settings to get them back to the “correct” values. I can only load the qml again to solve the problem.

Now I also want to use other colorschemes like the “DEM print” which can be found here:
http://soliton.vm.bytemark.co.uk/pub/cpt-city/td/tn/DEM_print.png.index.html

I guess the values for each color in this scheme are specified too, just like in “wikicarto 2”…?

I downloaded this scheme as svg file and imported it into QGIS 2.5 with the plugin “Svg2color”, then exported it as a xml “style” file.
This xml I then imported in the Style Manager.

I can now select the colorramp from inside the properties window of my DEM under “Generate new color map” in the dropdown list.

If I do this I then have to “Load values” in the section below and also click “classify” to get the style to show by clicking “Apply”. So somehow there is no “set” Information for value ranges inside this imported colorramp from cpt.

I also tried to just rename the xml file to qml but then I can´t load them through “Load Style”in the properties window (Error).

I then tried to use the “Wikicarto 2.0” as it can be found on cptcity in order to better understand how this all works by using the colorscheme I know from a different source and fileformat. On cpt city the “wikicarto 2.0” can be found here:
http://soliton.vm.bytemark.co.uk/pub/cpt-city/wkp/template/tn/wiki-2.0.png.index.html

If I import it into QGIS via the downloaded svg file and save it as an xml I again get the problem with the “correct” value ranges not being specified when selecting the WikiCarto 2.0 colorramp from the dropdown menu under “Generate new color map”. These values depend on how I set the Min/Max Values, classes and so on and only appear when I click on “classify”.

Maybe I somehow have to incorporate the info like segment count and valueranges given below the preview of the color ramp on cpt-city like this one here? I just don´t know where to enter it 🙁

enter image description here

To summarize:
I thought that inside the prepared colorramps I found there is also the information about the value ranges (corresponding to heights) for each color as desired by the author and I just want to know how to get this information from the downloaded svg or xml file into a qml-file so I can load it as easily as the wikicarto 2.0 scheme made by putting the code from the wikipage into a qml file.

Best Answer

I can't help on the details of QML and how to make colourmaps in QGIS, but I can give some info on the cpt-city gradients --- the "height information" is contained only in the CPT files, the values in the SVG files are normalised to be in the range from 0 -- 1. This is required by the SVG standard (and reflects the "graphic design" nature of SVG gradients). The CPT format is rather simple

z0 r g b z1 r g b
z1 r g b z2 r g b
 :

so you should be able to extract the values fairly easily (if tediously).

Some time ago, Etienne Tourigny created a "Color Ramp Manager" plugin for QGIS which contains a lot of cpt-city gradients, perhaps you could try that route first?