QGIS RGB Symbology – Using Field-to-RGB Mapping

qgisrgbsymbology

Using QGIS version 1.7.

I have a plain text file that lists a set of rgb values against a code. I want to use this colour table to colour a polygon layer by mapping one of its attribute fields ('map_symb') to a code in the text file.

the colour table is very long, and looks like this:

$ head gsv1Msymbology.txt
MAPCODE RED GREEN   BLUE
Oc  143 255 255
WAT 255 255 255
Qa  244 250 202
Qdl 195 239 218
Na  248 255 238
Qd2 227 255 190
Qxw 248 255 238
Qns 255 148 83
Qn  255 202 190
.... 

I want to match my 'map_symb' attribute to a value in MAPCODE, and use the corresponding RGB values to colour the polygons.

Is there a gui way to do this?

Best Answer

On later version of QGIS is easier to perform the requested task.

Just open Layer Properties, Style Tab, and make sure Single Symbol is selected. Click the box next to the "Fill" color and choose "Edit.

You will be editing the base color of your polygon bases on RGB colors present on the data table, with a constant border color (you can apply the same criteria if needed).

After hitting "Edit" just put the 3 RGB columns names of your table using the following expression:

color_rgb("R-column","G-column","B-column")

Ok, Apply and your done.

If you need to label and characterize the data in the same manner (for example, to build a legend), just use the Categorized option and apply the same expression to the Symbol and to the Column, identified in the image bellow.

enter image description here

Related Question