I have a raster map in GRASS containing elevation values. I want to display the elevation values in only one color (specificaly blue) but in varying shades of blue. I tried the options in r.colors, but none of those displays the map in monochrome.

1 Answer 1


In GRASS shell type:

> r.colors map=elevation color=rules 
> 0 white
> [your maximum elevation value] blue
> end
  • 4
    Or simply 0% white 100% blue.
    – Jake
    Mar 17, 2011 at 15:35
  • I tried creating a shell script containing: #!/bin/sh r.colors map=raster_bulacanOriginal2 color=rules 0 white 300 blue end and GRASS just kept on freezing
    – teamAngat
    Mar 17, 2011 at 16:22
  • 4
    It's not freezing, it's expecting input. If you want to use it in a shell script, you need to do something like #!/bin/sh echo -e '0 white\n300 blue' | r.colors map=<mapname> color=rules rules=-, which pipes the color rule to the r.colors command. The rules=- option tells r.colors to expect the rule from the pipe. Or you can save the color rule to a file, and use r.colors map=<mapname> color=rules rules=<rulesfile>.
    – Jake
    Mar 17, 2011 at 17:16
  • Thanks! I noticed that the color for the rules only uses color names. Can ASCII colors be used? I tried assigning a HEX color to a certain value and it produced this error: ERROR: bad rule (invalid color name): [-25 #00FFFF]
    – teamAngat
    Mar 18, 2011 at 8:54
  • 1
    According to grass.osgeo.org/grass62/manuals/html62_user/r.colors.html, you'd have to write '0 255 255' instead of '#00FFFF'.
    – underdark
    Mar 18, 2011 at 8:58

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.