Select to view content in your preferred language

Help with Arcade Expression

405
1
01-12-2022 09:54 AM
AshleighReeves
Emerging Contributor

I am trying to write a formula similar to the one below but with the option to say if within 1 standard deviation above or below then well below average or well above average. I am able to successfully get the equation to say just above or below. But how do I get the standard deviation portion?

 

var youth= $feature.MINOR_PERCENT;

IIf(youth < Average($layer, 'MINOR_PERCENT'), 'below average', 'above average');

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

There is actually a function for returning the standard deviation of a given set of values. Once you have that, you can just compare the individual feature's value with the mean and see if it falls outside of that range.

 

var lyr = $layer;

var lyr_mean = Mean($layer, 'MINOR_PERCENT');
var lyr_stdev = Stdev($layer, 'MINOR_PERCENT');

var youth = $feature.MINOR_PERCENT;

var deviation = Abs(lyr_mean - youth);

if(deviation > lyr_stdev){
    return 'Greater than 1 standard deviation'
} else {
    return 'Less than 1 standard deviation'
}

 

 

- Josh Carlson
Kendall County GIS