Find point feature count in multi-polygon feature layer with Arcade expression

252
2
11-30-2023 09:47 AM
Labels (1)
ellipsol
New Contributor III

I am working in ArcGIS Online and need to show the point feature count in a polygon layer with multiple features. I found a way to show the count, but it's not too meaningful yet: I need help iterating over the polygon features. Do you know how I can iterate over the polygon features by say fieldname1? 

var p = Portal("https://name.maps.arcgis.com");
// Point feature is incidents
var incidents = FeatureSetByPortalItem(p, "123rty", 0);
// Polygon feature is divisions
var divisions = FeatureSetByPortalItem(p, "abc123", 0);

// Iterate over divisions FeatureSet and get intersected incidents for each
for(var d in divisions) {
var inc_count = Count(Intersects(d, incidents))

Console('There are currently ' + inc_count + ' incidents in ')
0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Where are you using this expression? Is it for a Dashboard? Beyond the count, what else are you looking to show?

- Josh Carlson
Kendall County GIS
0 Kudos
ellipsol
New Contributor III

I'm using this expression in a label. It's in a map used in an Experience Builder. There's more fancy stuff I think about, but this is just to start.

0 Kudos