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
What features enable the Su-25 Frogfoot to operate with such a wide variety of fuels?
Is there a nicer/politer/more positive alternative for "negates"?
How do you make your own symbol when Detexify fails?
Which was the first story featuring espers?
Why Shazam when there is already Superman?
A variation to the phrase "hanging over my shoulders"
How much of a Devil Fruit must be consumed to gain the power?
How much theory knowledge is actually used while playing?
What is the difference between lands and mana?
Non-trope happy ending?
How would you translate "more" for use as an interface button?
Does grappling negate Mirror Image?
What kind of floor tile is this?
Why is so much work done on numerical verification of the Riemann Hypothesis?
Which Article Helped Get Rid of Technobabble in RPGs?
How can ping know if my host is down
The Digit Triangles
Review your own paper in Mathematics
What to do when eye contact makes your coworker uncomfortable?
What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?
What is the English pronunciation of "pain au chocolat"?
How to explain what's wrong with this application of the chain rule?
Mimic lecturing on blackboard, facing audience
Taxes on Dividends in a Roth IRA
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
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?

qgis attribute-table visualisation vector-layer
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.
add a comment |
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?

qgis attribute-table visualisation vector-layer
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
14 hours ago
@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
12 hours ago
add a comment |
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?

qgis attribute-table visualisation vector-layer
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?

qgis attribute-table visualisation vector-layer
qgis attribute-table visualisation vector-layer
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.
edited 14 hours ago
Ian Turton♦
49.9k547115
49.9k547115
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 14 hours ago
CasairoCasairo
112
112
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
14 hours ago
@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
12 hours ago
add a comment |
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
14 hours ago
@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
12 hours ago
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
14 hours ago
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
14 hours ago
@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
12 hours ago
@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
12 hours ago
add a comment |
3 Answers
3
active
oldest
votes
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.

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.
add a comment |
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 !
add a comment |
AS @J. Monticolo supposed, use Data defined expression in symbology properties.

For expression you can simply use:
replace("rgbfargko",' ',',')
Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:


add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.

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.
add a comment |
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.

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.
add a comment |
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.

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.
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.

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.
answered 14 hours ago
Ian Turton♦Ian Turton
49.9k547115
49.9k547115
add a comment |
add a comment |
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 !
add a comment |
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 !
add a comment |
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 !
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 !
edited 14 hours ago
answered 14 hours ago
J. MonticoloJ. Monticolo
1,155217
1,155217
add a comment |
add a comment |
AS @J. Monticolo supposed, use Data defined expression in symbology properties.

For expression you can simply use:
replace("rgbfargko",' ',',')
Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:


add a comment |
AS @J. Monticolo supposed, use Data defined expression in symbology properties.

For expression you can simply use:
replace("rgbfargko",' ',',')
Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:


add a comment |
AS @J. Monticolo supposed, use Data defined expression in symbology properties.

For expression you can simply use:
replace("rgbfargko",' ',',')
Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:


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

For expression you can simply use:
replace("rgbfargko",' ',',')
Which takse "rgbfargko" string and replace spaces whit commas for proper color formatting. See:


answered 13 hours ago
Oto KalábOto Kaláb
4,08231431
4,08231431
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
14 hours ago
@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
12 hours ago