AnsweredAssumed Answered

Dynamically counting points in Polygons

Question asked by sjacksonesriaustralia-com-au-esridist Employee on Oct 30, 2018
Latest reply on Oct 30, 2018 by sjacksonesriaustralia-com-au-esridist
  • I have a fairly large points layer in a hosted feature service - Lets call this incidents
    • This layer is frequently changing every couple of minutes with new records, deletes and updated locations.
  • I have a polygon layer as a hosted feature service - lets call this districts
    • A static layer that never changes shape.
  • This is all in ArcGIS Online.  No ArcGIS Enterprise in the mix.

 

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?

Outcomes