Hi All
Trying to create an arcade expression to populate a field, i am wanting to construct features using two arrays, is it possible to loop through multiple arrays in parallel (they are the same length), i know i can do this in python by using "for x,y in zip(x_list, y_list):"
DormArray = [FP1Dorm,FP2Dorm,FP3Dorm,ConDorm,MedDorm,BlisDorm]
DormWeightArray = [FP1DormWeight,FP2DormWeight,FP3DormWeight,ConDormWeight,MedDormWeight,BlisDormWeight]
var summarydict = {
fields:[
{'name':'Dormancy','type':'esriFieldTypeString'},
{'name':'DormancyWeight','type':'esriFieldTypeDouble'}],
'geometryType': '',
'features':[]
}
for (var d in DormArray and var w in DormWeightArray){
var new_f = {'attributes': {'Dormancy': d,
'DormancyWeight':w
}}
Push(summarydict.features, new_f)
Solved! Go to Solution.
Well i found this thread which helped me figure it out.
Rather than having two arrays i created a nested one and used an index to access the sub array values.
var DormArray = [[FP1Dorm,FP1DormWeight],[FP2Dorm,FP2DormWeight],[FP3Dorm,FP3DormWeight],[ConDorm,ConDormWeight],[MedDorm,MedDormWeight],[BlisDorm,BlisDormWeight]]
var summarydict = {
fields:[
{'name':'Dormancy','type':'esriFieldTypeString'},
{'name':'DormancyWeight','type':'esriFieldTypeInteger'}],
'geometryType': '',
'features':[]
}
for (var d in DormArray){
var new_f = {'attributes': {'Dormancy': DormArray[d][0],
'DormancyWeight':DormArray[d][1]
}}
Push(summarydict.features, new_f)
}
var predomDorm = first(groupby(featureset(text(summarydict)),'Dormancy',[{name:'DormSum',expression:'DormancyWeight',statistic:'SUM'}]))['Dormancy']
return predomDorm
Well i found this thread which helped me figure it out.
Rather than having two arrays i created a nested one and used an index to access the sub array values.
var DormArray = [[FP1Dorm,FP1DormWeight],[FP2Dorm,FP2DormWeight],[FP3Dorm,FP3DormWeight],[ConDorm,ConDormWeight],[MedDorm,MedDormWeight],[BlisDorm,BlisDormWeight]]
var summarydict = {
fields:[
{'name':'Dormancy','type':'esriFieldTypeString'},
{'name':'DormancyWeight','type':'esriFieldTypeInteger'}],
'geometryType': '',
'features':[]
}
for (var d in DormArray){
var new_f = {'attributes': {'Dormancy': DormArray[d][0],
'DormancyWeight':DormArray[d][1]
}}
Push(summarydict.features, new_f)
}
var predomDorm = first(groupby(featureset(text(summarydict)),'Dormancy',[{name:'DormSum',expression:'DormancyWeight',statistic:'SUM'}]))['Dormancy']
return predomDorm