As a user, I want to have a count of how many points there are in each polygon, along with perhaps some summary stats on the numerical fields from the incidents layer.
With a DBMS + ArcGIS Enterprise, I could create a nice Query layer and leverage ST_Intersects to have the polygons dynamically count how many features there are within them. But, I don't have access to these for this project.
I was looking at Arcade, but does not look like this is possible to reference a separate layer.
I was also looking at the Geometry Engine and the Contains method on a polygon in the Esri Javascript API (custom front-end logic is fine). This sounds client-heavy. I would have to send all incidents to the browser and then loop through each incident that is contained in each district to tally up scores, and then render. But, could be an option here. Could do with a sample snippet or pseudocode as a headstart...
There is the Spatial Join analysis tool, but the frequency this would need to be run (every couple of minutes) going to burn through my credits allowance fairly quick.
Anyone want to brainstorm this a little and offer a better suggestion I might not have thought of?
A Python funtion running every couple of minutes on AWS Lambda every with some non-arcpy libraries that perform the counts/summary stats?
Simon,
Why not just to a simple query on the map service for each district using a queryTask?
At the moment, I am investigating the use of doing this with a view. That way the crunching can be done server-side and looks like it won't incurr any credits.
Set hosted feature layer view definition—ArcGIS Online Help | ArcGIS
Will report back my findings...
Hi Simon,
Were you ever able to find a solution to this problem? I am wanting to do something similar and have yet to find a solid answer on this.
I would also like to do this but I would like it to display as dynamic text in an ArcPro layout. I am currently using a Count function to display the number of points in my layout but I need it to count the number of points that fall within the polygon in my layout.