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.
https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/SpatialAggregation.md
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.
Dan
// 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) {
n++
}
}
// 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.