Attribute rules, Count - Intersect no working.

824
2
Jump to solution
05-16-2022 05:26 PM
Labels (2)
EduardoDiaz
New Contributor II

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.

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

 

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);

 

JohannesLindner_1-1652775444776.png

 

 


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

 

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);

 

JohannesLindner_1-1652775444776.png

 

 


Have a great day!
Johannes
EduardoDiaz
New Contributor II

It works, thank you so much! (:

0 Kudos