Hey all, im looking to use attribute rules to populate a field of another featureclass with the count of intersecting features.
For example, Polygon B intersects Polygon A, in Polygons A table there is a field that has the count of all Polygons in Polygon B intersecting it, so if Polygon B has three polygons intersecting A, A's field shows the integer 3.
I was able to achieve this in a pop-up easy enough, but i cant quite get it to work in attribute rules.
"L16GridSystem15NM" would be "Polygon A" in the above exmaple, $feature would be B, This is what I have so far:
var geom2 = FeatureSetByName($datastore,"L16GridSystem15NM");
var Intersect = Intersects(geom2, $feature);
var AddList = []
var counter = 0
var total = Count(Intersect);
if (total > 0) {
for (var i in Intersect) {
AddList[total] + {
'globalid' : i.globalid,
'attributes': {
'RangeUsage': total
}
}
counter++
}
return {
"edit": [
{
'className' : "L16GridSystem15NM",
'updates' : [
{
'attributes' : {
'RangeUsage' : total
}
}
]
}
]
}
}
I have played around with different options from here:
https://www.esri.com/arcgis-blog/products/arcgis-pro/data-management/advanced-gdb-attribute-rules-editing-external-features-with-attribute-rules/
and documentation here:
https://pro.arcgis.com/en/pro-app/2.8/help/data/geodatabases/overview/attribute-rule-script-expression.htm#anchor4
I either had a error stating that globalid was not defined in the edit function or if i changed it to the current one above, it says that the Index is out of bounds (script line 😎
any help with this would be great!
Cheers
Keiran