Symbolize by mean (Arcade)

92
4
06-25-2019 11:08 AM
Highlighted
MVP Esteemed Contributor

In https://community.esri.com/message/860558-mean-for-all-features-not-just-one-arcade I was able to figure out how to set up a pop up to display the mean() of all the features in a given feature layer.  However, now I'm faced with the same requirement but for symbology.

As in the earlier post, I have the same polygon feature class of zipcodes, that represent monthly deliveries; for a given zipcode, there are twelve polygon features 'stacked' on top of each other, the result of monthly geoprocessing and appended to the zipcode polygon feature class.

Tags (1)
Reply
0 Kudos
4 Replies
Highlighted
Esri Esteemed Contributor

Options are rather limited in the symbology profile with Arcade in order no to affect the performance in drawing the layer. Options like $map, $layer and FeatureSetBy* functions are not available. If the data is static you can perform a field calculation using Arcade to calulate the mean. However, if the data is dynamic this might not be your best option.

Highlighted
MVP Esteemed Contributor

I wasn't sure of why, but some where in the help docs, it alludes to those as not being available.  I have a mix of static and dynamic data: the 2018 data is static while the 2019 data will be dynamic till January 2020, and so on....

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

So the field calculation could be something like this (for the static data or you would have to repeat the calculation each month as new data comes in). 

var zipcode = $feature.zipcode;
var sql = "zipcode = '" + zipcode + "'";
var zipcode_layer = FeatureSetByName($datastore, "Name of your zipcode layer in the datastore", ["zipcode", "DeliveryCount"], False);
var zipcode_features = Filter(zipcode_layer, sql);
return Average(zipcode_features, "DeliveryCount");

Another reason of not doing this dynamically in the symbology profile is the fact that it will draw 12 polygons (for 1 year) on top of each other and it will have to do the same calculation for each polygon, when only one will be visible.

Highlighted
MVP Esteemed Contributor

The monthly data gets processed via Python as a scheduled taks; I could add an actual field to the data structure in the python code and re-calc it as part of that process.  Just another couple lines of code, but lately I've had this thing about not adding fields per se....

Reply
0 Kudos