Select to view content in your preferred language

Using Arcade to get count of all points in ALL polygons, not per polygon

04-21-2023 04:06 AM
Labels (1)
New Contributor

Hi all,

I am using Enterprise v 10.9.1.

I am trying to add an indicator to a dashboard to show the total number of points that fall within all the polygons.

I have 2 feature layers.  One is points, one is polygons.

Some points fall within one polygon.

Some points fall within multiple polygons.

Some points don't fall within any polygons.

The polygon layer is updated regularly (daily) with new polygons added and some existing polygons removed.

I am looking to use an arcade expression to get the count of points that fall within all the polygons and show this on an indicator in a dashboard.  I am not interested in the count per polygon, but instead the total number of points that are within the polygons.

If a point intersects multiple polygons it still only counts as 1.

So far I have found this example in esri's GitHub repository.

This works, but this returns the count per polygon. I am unable to use this count to sum the point counts as some points fall within multiple polygons.

I have found other examples which rely on the user selecting a polygon from the map, which then returns the count for that polygon.

Does anybody have an example showing how to do this?

Many thanks.









Tags (2)
0 Kudos
1 Reply
MVP Frequent Contributor
// load the layers
var points = FeaturesetByPortalItem(...)
var polygons = FeaturesetByPortalItem(...)

var n = 0
// iterate over the points
for(var p in points) {
    // if it intersects one or more polygons, increase the counter
    if(First(Intersects(p, polygons)) != null) {

// return a featureset with one field and one feature
var out = {
    geometryType: "",
    fields: [ {name: "Inside", type: "esriFieldTypeInteger"} ],
    features: [{attributes: {Inside: n}}]
return Featureset(Text(out))


You can then use the MIN/MAX/SUM of this field in your indicator.

Have a great day!
0 Kudos