5

I would like to use a set of color ramps that are available at CPT-CITY but cannot find any way to import the downloaded files.

Note that I have found the Catalog: cpt-city option under the Create New Color Ramp selection. However, the ramps that I'm interested are not found in this collection.

Is there some way to simply browse to the file that I'm interested in to register it with my QGIS project?

4 Answers 4

7

The solution proposed by @Xi Jin is available for raster layers only and is for color maps, not color ramps. Even though very similar, the concepts are different: a color map assigns pre-defined colors (could be a color ramp) to certain values (numbers or classes) - like assigning elevation data to a topographic color ramp: 0 to 200 m: green; 200 to 500 m: yellow; 500 to 1000 m: brown; over 1000 m: white. Thus color maps are a more narrow concept: color ramp are just ordered gradients of colors, without assigning actual values: green, yellow, brown, white. See also here for color maps: https://pvanb.wordpress.com/2014/02/05/creating-a-qgis-color-map-from-text-file/

The standard way to import color ramps from a file or a URL is using Menu Settings / Style Manager, where you have a button to import/export files - see documentation for Style Manager. The color ramps you add in this way will permanently be available everywhere in QGIS.

enter image description here

If you want to create your own color ramps, click the green + symbol. You can add a Name and Tag(s) for the color ramps created to be easier to find/identify them when you have a lot of color ramps.

Color ramps created in this way can be exported (to share) again with the button on the left.

For all color ramps you create or import, set the checkbox Add to favorites for those color ramps that you want to be added to favorites. They will be immediately visible in the drop down list when selecting color ramps - all others are hidden behind All Color Ramps:

enter image description here

Assigning names and tags helps you to keep an overview of your color ramps and other styles.

By the way, the style managar can be used in the same way for other styles like composed styles for vector layers (points, lines, polygons), for texts/labels, legend symbos and 3D symbols. So it is a powerful tool to create and administrate everything connected with styles.

2
  • Thanks, but this isn't really importing the color ramps in QGIS. Rather, it allows one to select them from the catalog to be displayed in a more convenient manner. What I wish to do is to add several CPT color ramps which are not already in the QGIS system, and which I have as separate text files. It's utterly maddening that this seems to have been overlooked.. I apologise for the delay in getting back to you. I'd run into worse issues: no electricity! Commented Feb 3, 2021 at 0:57
  • Use the button to import/export , not the green +, than external files, not just selecting from the catalog, will actually be imported. However, as you state, you can't convert files this way, just import XML files. Great you added your answer as well.
    – Babel
    Commented Feb 3, 2021 at 6:18
2

You can load color maps from "load color map" button. Look at the picture, it is in red circle.

enter image description here

1
  • 1
    Thank you, but I am looking for a way to import color ramp, not map. (.cpt) Commented Feb 3, 2021 at 1:07
1

After rephrasing my question a little, I found this answer to a similar query.

The problem was that I could only import XML files, and I didn't know how to convert from CPT to XML. It should have been obvious to simply export an existing ramp as XML, modify it for the values i wanted, and import as my new ramp.

The CPT that I wanted has stops, not in elevation, but of the form 0, 1, 2, .. 125. These need to be between 0-1 for the XML. The CPT has 126 lines, so I updated each to be $line-number / 125 and it works reasonably ok.

The XML wants them concatenated as one long value of a single tag. eg.

STOP;R,G,B,A or 0.4206;189,175,198,255

Each of these sets should be concatenated to the next with a colon (:)

1

This document has directions on adding color ramps from the cpt-city website towards the end https://psqgis.org/downloads/QGIS_3.4_color_ramps.doc

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Oct 13, 2023 at 21:01
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Vince
    Commented Oct 13, 2023 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.