I want to give multiple colors to different features within a shapefile based on attribute values , is this possible in QGIS ?

If yes what is the procedure ?

Is there a way to provide color by means of hexadecimal codes ?


You can change the styles of the shape file in the layer properties. Double click the layer and select style.

Select Categorized style and choose a field you want to visualize. Remember to classify your values before leaving the dialog.

Style dialog in QGIS 2.

  • 2
    Just a note that this has changed since the answer was written. It now accessed by Layer Properties -> Symbology.
    – RichardM
    Oct 29 '20 at 14:00

if I understood you right this great tutorial should answer your question: http://woostuff.wordpress.com/2011/06/06/one-of-my-favorite-features-of-qgis/

p.s. from the same author there is also a follow-up: http://woostuff.wordpress.com/2012/01/25/improvements-to-the-qgis-rule-based-rendering/

  • 1
    yes actually your answer is more pertinent to my question but i accepted the other as answer was for a more general case
    – GeoH2O
    Feb 16 '12 at 17:22

Alternatively to categorized styling, if you want to play a bit with colour you can try to code it by yourself:

    WHEN Field = 'Value1' THEN color_rgb(0, 176, 80) 
    WHEN Field = 'Value2' THEN color_rgb(255, 255, 0)
    WHEN Field = 'Value3' THEN color_rgb(255, 192, 0)
    WHEN Field = 'Value4' THEN color_rgb(255, 0, 0)
    WHEN Field = 'Value5' THEN color_rgb(192, 0, 0) 
    WHEN Field = 'Value6' THEN color_rgb(255, 0, 255)
    color_rgb(0, 0, 0)    

You can also apply rand function inside color_rgb

  • 1
    Using a Graduated style will produce the same result, without having to code anyting.
    – Hakim
    Feb 19 '18 at 18:16

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.