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

Here, I wish to make my own color gradient for SRTM raster layer using RGB values.

  1. Red and green will describe the color every 255m. Basic equation for R and G is height = R + (G*255). Here, if height is 500m, this will be 245 + (1*255), so RGB value will be (245, 1, 24). If height is 1000m, this will be 235 + (3*255), so RGB value will be (235, 3, 40). Value for blue is explained below.
  2. Blue will be used as some sort of "category" of height. B increase 8 for every 255m from -512m (it starts from -512m), up to B=255. For example, From -512m~-256m height, B=0. From -255m~0m height, B=8. From 1m~255m, B=16. From 256m~512m, B=24... Accordingly, above example of 500m should be (245, 1, 24), and 1000m should be (235, 3, 40)

This way, I wish to create my own color gradient scheme, to express height using specific RGB numbers. I'm trying raster calculator now, but as a beginner, making equation is not easy for me.

What should be the variable names for R, G, and B values?

I have one raster layer name "SRTM@1". I was thinking of equations like "SRTM@1" = "Red" + 255*"Green", but of course it is not working. I'm not sure if this is correct expression for RGB, and if my logic behind this equation is correct from raster calculator.

  • My question is: why do you want to modify the elevation values. Why not just apply a color gradient in symbology? – Gabriel C. Nov 27 '18 at 21:08
  • @GabrielC. One of group project requires to make a such color gradient scheme. Others used Global Mapper, but that is too expensive for me, so I'm relying on free software like QGIS. – exsonic01 Nov 27 '18 at 22:00
  • And the raster values themselves need to be permanently modified? – Gabriel C. Nov 28 '18 at 12:25
  • @GabrielC. I'm not sure if I understand your question correctly. Currently there is only one raster layer, SRTM data I downloaded. I wish to change color gradient, using equations I suggested above. It is OK to modify original raster data, because I just can duplicate the original one. – exsonic01 Nov 29 '18 at 1:23
  • Are you looking to replicate what users can do with custom shaders in Global Mapper? I'm not sure it'll be easy to do in QGIS but at least I'm pretty positive raster calculator isn't the tool you need to use as this modifies the cell values (depending on your raster this could be an integer or float value but never a color combination) and has no incidence on how it will be rendered. – Gabriel C. Nov 29 '18 at 4:41

Your Answer

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

Browse other questions tagged or ask your own question.