Assign a specific color to vector layer based on RGB codes in attribute tableAssign multiple colors to features within a single vector layerPyQGIS: how to delete layer from TOC when attribute table is closed?Finding out and editing specific rows of attribute table in line shapefile using Python?How to save color VALUE to attribute table in QGIS for a vector layer with a graduated symbol rendererLine symbology based on a field for color AND size (linewidth)Fill in new field in attribute table based on the values of another field in GISTransfering vector Style classification into Attribute table in QGIS?Converting 8-bit RGB tif to single gray-scale imageHow to edit the attribute tabel of a shapefile when the enable editing is greyed out?Filter vector layer by searching through complete attribute table - limitations and improvements

How does it work when somebody invests in my business?

Increase performance creating Mandelbrot set in python

Trouble understanding the speech of overseas colleagues

A Rare Riley Riddle

Do sorcerers' Subtle Spells require a skill check to be unseen?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Is this apparent Class Action settlement a spam message?

Proof of work - lottery approach

Go Pregnant or Go Home

Is `x >> pure y` equivalent to `liftM (const y) x`

Implement the Thanos sorting algorithm

How can a function with a hole (removable discontinuity) equal a function with no hole?

What does "I’d sit this one out, Cap," imply or mean in the context?

What is paid subscription needed for in Mortal Kombat 11?

Is there a problem with hiding "forgot password" until it's needed?

Arithmetic mean geometric mean inequality unclear

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

How do I go from 300 unfinished/half written blog posts, to published posts?

Is a stroke of luck acceptable after a series of unfavorable events?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Method to test if a number is a perfect power?

How did Arya survive the stabbing?

Shortcut for value of this indefinite integral?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?



Assign a specific color to vector layer based on RGB codes in attribute table


Assign multiple colors to features within a single vector layerPyQGIS: how to delete layer from TOC when attribute table is closed?Finding out and editing specific rows of attribute table in line shapefile using Python?How to save color VALUE to attribute table in QGIS for a vector layer with a graduated symbol rendererLine symbology based on a field for color AND size (linewidth)Fill in new field in attribute table based on the values of another field in GISTransfering vector Style classification into Attribute table in QGIS?Converting 8-bit RGB tif to single gray-scale imageHow to edit the attribute tabel of a shapefile when the enable editing is greyed out?Filter vector layer by searching through complete attribute table - limitations and improvements













3















I use QGIS and have a geological map for a large area. I present this after ID codes based on the geology ("Geokartnr" in photo).



I want to use international/nation color codes for each rock type, this way it will be comparable to other peoples work. The international colors is already added to the attribute table as a RGB code ("RGBfargko"). Is there any way I can sort/present the maps by "geokartnr" code and present this by the color codes in the RGB codes in the attribute table? Or do I need to change all colors manually?



Screenshot of the attribute table










share|improve this question









New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

    – J.R
    Mar 21 at 10:00











  • @J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

    – Oto Kaláb
    Mar 21 at 11:08
















3















I use QGIS and have a geological map for a large area. I present this after ID codes based on the geology ("Geokartnr" in photo).



I want to use international/nation color codes for each rock type, this way it will be comparable to other peoples work. The international colors is already added to the attribute table as a RGB code ("RGBfargko"). Is there any way I can sort/present the maps by "geokartnr" code and present this by the color codes in the RGB codes in the attribute table? Or do I need to change all colors manually?



Screenshot of the attribute table










share|improve this question









New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

    – J.R
    Mar 21 at 10:00











  • @J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

    – Oto Kaláb
    Mar 21 at 11:08














3












3








3


1






I use QGIS and have a geological map for a large area. I present this after ID codes based on the geology ("Geokartnr" in photo).



I want to use international/nation color codes for each rock type, this way it will be comparable to other peoples work. The international colors is already added to the attribute table as a RGB code ("RGBfargko"). Is there any way I can sort/present the maps by "geokartnr" code and present this by the color codes in the RGB codes in the attribute table? Or do I need to change all colors manually?



Screenshot of the attribute table










share|improve this question









New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I use QGIS and have a geological map for a large area. I present this after ID codes based on the geology ("Geokartnr" in photo).



I want to use international/nation color codes for each rock type, this way it will be comparable to other peoples work. The international colors is already added to the attribute table as a RGB code ("RGBfargko"). Is there any way I can sort/present the maps by "geokartnr" code and present this by the color codes in the RGB codes in the attribute table? Or do I need to change all colors manually?



Screenshot of the attribute table







qgis attribute-table visualisation vector-layer






share|improve this question









New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Mar 21 at 9:49









Ian Turton

50k547116




50k547116






New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 21 at 9:39









CasairoCasairo

162




162




New contributor




Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Casairo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

    – J.R
    Mar 21 at 10:00











  • @J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

    – Oto Kaláb
    Mar 21 at 11:08


















  • Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

    – J.R
    Mar 21 at 10:00











  • @J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

    – Oto Kaláb
    Mar 21 at 11:08

















Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

– J.R
Mar 21 at 10:00





Be aware that by using an expression to set the color as stated answer below you wont be able to automatically generate a legend.... (so the problem is you either set the color manually OR create the legend manually....)

– J.R
Mar 21 at 10:00













@J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

– Oto Kaláb
Mar 21 at 11:08






@J.R Good point, I think its kind of bug, because I suppose that it will generate legend if you use Categorized symbology (with rgb field as category). You can manually change a symbol of every each category, but if the data defined values are set for color, the value is just not taken from the expression. Or I am missing something?

– Oto Kaláb
Mar 21 at 11:08











3 Answers
3






active

oldest

votes


















5














In the layer styles panel if you click on simple marker, there is a small box to the right of the fill color combo box - if you click on it you can select edit from the menu and enter the expression editor.



enter image description here
You will need an expression like this, to convert your string's spaces to commas and then into a colour:



color_rgb( replace("rgbfargeko",' ',','))


Then click ok and your colors should show up.






share|improve this answer

























  • You missed a closing bracket ).

    – ahmadhanb
    Mar 22 at 1:55


















3














AS @J. Monticolo supposed, use Data defined expression in symbology properties.



enter image description here



For expression you can simply use:



replace("rgbfargko",' ',',')


Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:



enter image description here



enter image description here






share|improve this answer






























    2














    In the layer properties, in the symbology tab, define the color by an expression (link to the QGIS doc) :



    color_rgb(
    array_get(string_to_array("rgbfargko", ' '), 0),
    array_get(string_to_array("rgbfargko", ' '), 1),
    array_get(string_to_array("rgbfargko", ' '), 2)
    )


    Explanation of the code :



    1- function string_to_array : transform the field data into an array by splitting at the white space character ;
    2- function array_get : get elements of the array, the first item has an index of 0 ;
    3- function color_rgb : with 3 arguments (R, G, B), this function return a QGIS color.



    EDIT
    The solution of @Ian Turton is more visual and simple !






    share|improve this answer
























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "79"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Casairo is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316218%2fassign-a-specific-color-to-vector-layer-based-on-rgb-codes-in-attribute-table%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      In the layer styles panel if you click on simple marker, there is a small box to the right of the fill color combo box - if you click on it you can select edit from the menu and enter the expression editor.



      enter image description here
      You will need an expression like this, to convert your string's spaces to commas and then into a colour:



      color_rgb( replace("rgbfargeko",' ',','))


      Then click ok and your colors should show up.






      share|improve this answer

























      • You missed a closing bracket ).

        – ahmadhanb
        Mar 22 at 1:55















      5














      In the layer styles panel if you click on simple marker, there is a small box to the right of the fill color combo box - if you click on it you can select edit from the menu and enter the expression editor.



      enter image description here
      You will need an expression like this, to convert your string's spaces to commas and then into a colour:



      color_rgb( replace("rgbfargeko",' ',','))


      Then click ok and your colors should show up.






      share|improve this answer

























      • You missed a closing bracket ).

        – ahmadhanb
        Mar 22 at 1:55













      5












      5








      5







      In the layer styles panel if you click on simple marker, there is a small box to the right of the fill color combo box - if you click on it you can select edit from the menu and enter the expression editor.



      enter image description here
      You will need an expression like this, to convert your string's spaces to commas and then into a colour:



      color_rgb( replace("rgbfargeko",' ',','))


      Then click ok and your colors should show up.






      share|improve this answer















      In the layer styles panel if you click on simple marker, there is a small box to the right of the fill color combo box - if you click on it you can select edit from the menu and enter the expression editor.



      enter image description here
      You will need an expression like this, to convert your string's spaces to commas and then into a colour:



      color_rgb( replace("rgbfargeko",' ',','))


      Then click ok and your colors should show up.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 22 at 8:13

























      answered Mar 21 at 9:56









      Ian TurtonIan Turton

      50k547116




      50k547116












      • You missed a closing bracket ).

        – ahmadhanb
        Mar 22 at 1:55

















      • You missed a closing bracket ).

        – ahmadhanb
        Mar 22 at 1:55
















      You missed a closing bracket ).

      – ahmadhanb
      Mar 22 at 1:55





      You missed a closing bracket ).

      – ahmadhanb
      Mar 22 at 1:55













      3














      AS @J. Monticolo supposed, use Data defined expression in symbology properties.



      enter image description here



      For expression you can simply use:



      replace("rgbfargko",' ',',')


      Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:



      enter image description here



      enter image description here






      share|improve this answer



























        3














        AS @J. Monticolo supposed, use Data defined expression in symbology properties.



        enter image description here



        For expression you can simply use:



        replace("rgbfargko",' ',',')


        Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:



        enter image description here



        enter image description here






        share|improve this answer

























          3












          3








          3







          AS @J. Monticolo supposed, use Data defined expression in symbology properties.



          enter image description here



          For expression you can simply use:



          replace("rgbfargko",' ',',')


          Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:



          enter image description here



          enter image description here






          share|improve this answer













          AS @J. Monticolo supposed, use Data defined expression in symbology properties.



          enter image description here



          For expression you can simply use:



          replace("rgbfargko",' ',',')


          Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:



          enter image description here



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 21 at 10:05









          Oto KalábOto Kaláb

          4,12831431




          4,12831431





















              2














              In the layer properties, in the symbology tab, define the color by an expression (link to the QGIS doc) :



              color_rgb(
              array_get(string_to_array("rgbfargko", ' '), 0),
              array_get(string_to_array("rgbfargko", ' '), 1),
              array_get(string_to_array("rgbfargko", ' '), 2)
              )


              Explanation of the code :



              1- function string_to_array : transform the field data into an array by splitting at the white space character ;
              2- function array_get : get elements of the array, the first item has an index of 0 ;
              3- function color_rgb : with 3 arguments (R, G, B), this function return a QGIS color.



              EDIT
              The solution of @Ian Turton is more visual and simple !






              share|improve this answer





























                2














                In the layer properties, in the symbology tab, define the color by an expression (link to the QGIS doc) :



                color_rgb(
                array_get(string_to_array("rgbfargko", ' '), 0),
                array_get(string_to_array("rgbfargko", ' '), 1),
                array_get(string_to_array("rgbfargko", ' '), 2)
                )


                Explanation of the code :



                1- function string_to_array : transform the field data into an array by splitting at the white space character ;
                2- function array_get : get elements of the array, the first item has an index of 0 ;
                3- function color_rgb : with 3 arguments (R, G, B), this function return a QGIS color.



                EDIT
                The solution of @Ian Turton is more visual and simple !






                share|improve this answer



























                  2












                  2








                  2







                  In the layer properties, in the symbology tab, define the color by an expression (link to the QGIS doc) :



                  color_rgb(
                  array_get(string_to_array("rgbfargko", ' '), 0),
                  array_get(string_to_array("rgbfargko", ' '), 1),
                  array_get(string_to_array("rgbfargko", ' '), 2)
                  )


                  Explanation of the code :



                  1- function string_to_array : transform the field data into an array by splitting at the white space character ;
                  2- function array_get : get elements of the array, the first item has an index of 0 ;
                  3- function color_rgb : with 3 arguments (R, G, B), this function return a QGIS color.



                  EDIT
                  The solution of @Ian Turton is more visual and simple !






                  share|improve this answer















                  In the layer properties, in the symbology tab, define the color by an expression (link to the QGIS doc) :



                  color_rgb(
                  array_get(string_to_array("rgbfargko", ' '), 0),
                  array_get(string_to_array("rgbfargko", ' '), 1),
                  array_get(string_to_array("rgbfargko", ' '), 2)
                  )


                  Explanation of the code :



                  1- function string_to_array : transform the field data into an array by splitting at the white space character ;
                  2- function array_get : get elements of the array, the first item has an index of 0 ;
                  3- function color_rgb : with 3 arguments (R, G, B), this function return a QGIS color.



                  EDIT
                  The solution of @Ian Turton is more visual and simple !







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 21 at 9:55

























                  answered Mar 21 at 9:49









                  J. MonticoloJ. Monticolo

                  1,171217




                  1,171217




















                      Casairo is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Casairo is a new contributor. Be nice, and check out our Code of Conduct.












                      Casairo is a new contributor. Be nice, and check out our Code of Conduct.











                      Casairo is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f316218%2fassign-a-specific-color-to-vector-layer-based-on-rgb-codes-in-attribute-table%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                      Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

                      Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High