I'm using QGIS 3.4.1, and downloaded the SRTM data for the area of my interest, and added the TIFF format SRTM data file to my project using "add raster layer" option.

Here, I wish to change the contour color gradient for SRTM data from property-symbology menu. More precisely, I wish to color the height in terms of RGB value. For the project of mine, I only need to use red and green colors.

Following is the detail:

Formula is (Red Channel) + (Green Channel * 255).

For example: if a pixel value is RGB (171,1,0) then the height is (171) + (1 * 255) = 426

Another example: if a pixel value is RGB (107,2,0) then the height is (107) + (2 * 255) = 617

How can I differ my contour color for my raster layer (SRTM TIFF file) in the same way with those example?


You can do it with a quick raster calculation.
In the top menu, look for raster then raster calculator. In there, enter your formula and generate a single layer with the values you want to apply the style to.
Then open the style dialog for that raster layer and apply your favourite colour scale. Done.

  • Thank you. Could you help me detail of raster calculator? I checked docs page (docs.qgis.org/2.8/en/docs/user_manual/working_with_raster/…) But I'm not sure how to set up the equation using RGB values following that equation.
    – exsonic01
    Nov 26 '18 at 16:41
  • If your layer is RGB, in the calculator it should display @1, @2 and @3 at the end of the layer name to acknowledge it contains three different bands (R,G,B in that order). So if you want to do (Red Channel) + (Green Channel * 255), you can enter it into the calculator as layername@1 + layername@2 * 255
    – jberrio
    Nov 27 '18 at 23:44
  • Thank you. I only have on raster which I downloaded from other site. But I duplicated that raster, and gave red/green/blue color ramp from singleband pseudocolor. Would it be enough?
    – exsonic01
    Nov 28 '18 at 1:44
  • Well, I tried the method I mentioned above (duplicate and give singleband pseudocolor), but it is not working :P Now I really have no clue what to do. But thanks for your time and help for me though.
    – exsonic01
    Nov 28 '18 at 1:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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