9

I have a layer containing color field storing color names as text like red, green. The layer is read-only.

id  color 
1   green
2   red
3   blue
4   green

I would like to define -using data-defined override- the color of features using those color names. I reviewed the color functions in Expression window, but I couldn't find a suitable one.

enter image description here

Is there a way to define a color using color names?

6
  • 5
    Doesn't it work if you set your Symbol Color property to be by expression, expression simply being color
    – Kasper
    Mar 11, 2023 at 15:09
  • 4
    Use a "Single Symbol" in the symbology and set the field name in the expression for the full colour. Works for me.
    – Spacedman
    Mar 11, 2023 at 15:18
  • @Kasper Believe me, I didn't think it was that simple. Can you add it as an answer, please? Mar 11, 2023 at 18:15
  • @kadir Hard to believe, but I have to !
    – Kasper
    Mar 11, 2023 at 21:47
  • BTW is there opportunity to use local color names? Like 'rouge' or 'Rot' or 'წითელი' instead of 'red'?
    – RainForest
    Mar 12, 2023 at 5:27

1 Answer 1

7

Tried to follow idea of @Kasper and @Spacedman.

I was amazed, but it really is that simple.

  1. Open layer properties panel
  2. Select style as "Single symbol"
  3. Sel fill color as data defined.
  4. Choose the field containing text strings of feature color. It's "code" in my example or "color" in question. That's all.

enter image description here

0

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.