AnsweredAssumed Answered

Using Arcade to color code a polygon layer based on attribute values  

Question asked by H.Bouckaert_westernpower on Oct 22, 2018
Latest reply on Oct 24, 2018 by xander_bakker

Hi 

 

In a map I use a "Custom Expression" to change the rendering style of a polygon layer, and use Arcade to make a custom expression. In Arcade, I combine all possible combinations of two fields. One field is named PIP and the other BIOSECURITY. Both use the same domain, namely a simple YES/NO choice where the code for "NO" = 0 and the code for YES = 1. However both fields can also be empty.

 

The logic is that I use decode to change the values of PIP differently from those of BIOSECURITY so they can never be the same. Once that is done, I add them up. Because the values are always different, each addition should be unique. I use a WHEN statement in which I add up the unique combinations of the values in the two fields. 

 

WHEN

(Decode($feature.PIP, 0, 2, 1, 4, 5) + Decode($feature.BIOSECURITY, 0, 22, 1, 32, 55) == 60,'Unique Color Code',

Decode($feature.PIP, 0, 2, 1, 4, 5) + Decode($feature.BIOSECURITY, 0, 22, 1, 32, 55) == 59, 'Another Unique Color Code',  'Default Value ')

 

But where I write 'Unique Color Code',  and ''Another Unique Color Code' I would actually like to instruct Arcade to render those layers with a particular color, e.g. green or red.  

 

I found some examples, but I think is for when you embed Arcade in JavaScript  

 

Decode($feature.PIP, 0, 2, 1, 4, 5) + Decode($feature.BIOSECURITY, 0, 22, 1, 32, 55) == 60, 'background-color:ff984f'

I also tried:  

Decode($feature.PIP, 0, 2, 1, 4, 5) + Decode($feature.BIOSECURITY, 0, 22, 1, 32, 55) == 60, '#ff984f'

 

Is there any way in Arcade to directly assign colors to a polygon layer, based on a WHEN statement, as in the code snippet above?

 

Thanks

 

Hugo 

 

 

Outcomes