count the number of points in a polygon using dynamic text in ArcGIS Pro

844
3
08-18-2021 09:08 AM
SarahHartholt
Occasional Contributor III

Hi everyone,

I would like to use dynamic text to display the number of points that fall within a polygon feature class in my ArcPro layout (*bonus points for an expression that only counts distinct ID values from my points layer*). Is this possible? This is what I have so far and keep getting an error: 

var point = $feature;
var polygon = FeatureSetByName($datastore, "Buffer_of_Site_Address_Points_500m", ["BufferDist"], True);
var STA = Intersects(point, polygon)
var cnt = Count(STA);
return cnt;

 

SarahHartholt_0-1629302877436.png

 

0 Kudos
3 Replies
Robert_LeClair
Esri Notable Contributor

Hi Sarah - not using dynamic text in a layout but one of my students asked a similar question yesterday and I found this blog article that works within a Map View.  Perhaps this is something worth exploring?

0 Kudos
SarahHartholt
Occasional Contributor III

Thanks for the suggestion. I don't think I can do it that way - my polygon layer is stored in a file geodatabase so I don't think it's possible for me to create the query layer.

SarahHartholt
Occasional Contributor III

I think I'm getting close here. I have an expression that counts the number of points in a polygon BUT it currently displays as a list. Can someone let me know which expression I can use to Sum/Count the number of intersections so that my expression reads: "Existing: 14", rather than "Existing: 1 1 1 1 1 1.. "?

var container = FeatureSetByName($datastore, "Buffer_of_Site_Address_Points_500m", ["BufferDist"], True);
var STA = Sum(Count(Intersects(container, Geometry($feature))));
return STA

SarahHartholt_0-1630416404587.png

 

0 Kudos