4

I have Four columns like MapCode R G B, I would like to create my own colour from the attribute table(R, G, B-Column) for Mapcode.

I would like to apply symbology based on MapCode values(which is unique) and I have the color Values (R, G, B,) as seprate Columns in the same table. how to create color ramps for unique map_code

MapCode, R, G, B


AB1C, 243, 255, 128


BB12, 124, 125, 120


enter image description here

4
  • Not really sure what you want to do. Can you explain a little further? To get a color from your columns use data defined override and an expression like "R"||','||"G"||','||"B"||','||255. May I ask what you want to do with python and plugins?
    – MrXsquared
    Commented May 30, 2019 at 18:06
  • I would like to apply symbology based on MapCode values(which is unique) and I have the color Values (R, G, B,) as seprate Columns in the same table, is there any plugins or python code available to do that
    – Gobinath
    Commented May 30, 2019 at 18:09
  • You dont need plugins to do that. Data defined symbology definition is a core feature of QGIS. Possible using python too, but as I interpret your question, there is no need for it. Can you give an example how a symbol shall look like when MapCode is AB1C and how if MapCode is BB12?
    – MrXsquared
    Commented May 30, 2019 at 18:14
  • can u please have a look on that pic so that it will be easy to understand
    – Gobinath
    Commented May 30, 2019 at 18:25

1 Answer 1

3

Go to the Layer Properties and the Symbology tab

Depending on the layer type just select a simple fill, or a simple line instead of a categorized symbol.

Next to the "Fill color" or "Stroke color" whatever you are wanting colored, and there is a drop down select next to it. Select Edit... from the drop down which will bring up the Expression String Builder

enter image description here

Put in this expression color_rgb( "R","G","B")

where "R" "G" and "B" represent the column names that contain your RGB values.

I added some random RGB values to a USA state layer and this was the result

USA random assigned colors

3
  • Thanks, @TJ Rockefeller., It works for me but still, I have problems while exporting for web(using qgis2web plugin) it takes only one colour not the classified colours everything shows a single colour. how do I rectify this problem?
    – Gobinath
    Commented Jun 3, 2019 at 11:21
  • @Gobinath Sorry to hear that this isn't working for export to the web. I don't have any experience with the qgis2web plugin, and you may need to ask another question specific to qgis2web.
    – TJR
    Commented Jun 3, 2019 at 13:22
  • Thank you. @TJ Rockefeller ... I'll rise one more question with detailed screenshots... Thank you very much
    – Gobinath
    Commented Jun 3, 2019 at 13:24

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.