Attribute rules in ArcGIS Pro 2.9.3.
I designed a rule that extracts a field to concatenate it with the result of the intersection of a point layer, the problem is that the result of the intersection count is always one. The first extract has no errors.
Rule on field cve_punto:
var intersectMUN = Intersects(FeatureSetbyName($datastore,"BajaCalifornia"), $Feature);
var mun = "";
for(var f in intersectMUN){
mun = (f.CVE_MUN) +" - "+Count(intersectMUN);
}
return mun;
______________
Triggers: Insert
BajaCalifornia - Polygon Layer
$Feature - Points Layer
The expected result is something like: 001 - 1, 001 - 2, 001 - 3; where the sequence 1,2,3 grow when a new point is added. On the other hand I need it to be a sequence for each CVE_MUN identifier, 001 - 1, 001 - 2, 001 -3; 002 - 1, 002 - 2, 002 - n.
I'm a newbie with Arcade.
Solved! Go to Solution.
You're halfway there.
You're using the count of the intersection between your point $feature and the polygons, which is always 1 (assuming no overlapping polygons). When you got your polygon feature, you have to intersect that again with the point fc to get the point count:
// get intersecting polygons
var intersectMUN = Intersects(FeatureSetbyName($datastore,"BajaCalifornia"), $feature);
// get the first polygon or return null
var firstMUN = First(intersectMUN)
if(firstMUN == null) { return null }
// get the points intersecting the polygon
var intersectPoints = Intersects(FeatureSetByName($datastore, "POINTS"), firstMUN);
// return "PolygonID - PointCount"
return (firstMUN.CVE_MUN) + " - " + Count(intersectPoints);
You're halfway there.
You're using the count of the intersection between your point $feature and the polygons, which is always 1 (assuming no overlapping polygons). When you got your polygon feature, you have to intersect that again with the point fc to get the point count:
// get intersecting polygons
var intersectMUN = Intersects(FeatureSetbyName($datastore,"BajaCalifornia"), $feature);
// get the first polygon or return null
var firstMUN = First(intersectMUN)
if(firstMUN == null) { return null }
// get the points intersecting the polygon
var intersectPoints = Intersects(FeatureSetByName($datastore, "POINTS"), firstMUN);
// return "PolygonID - PointCount"
return (firstMUN.CVE_MUN) + " - " + Count(intersectPoints);
It works, thank you so much! (: