I am trying to script a process where I need to make a selection on a point feature class, count the number of points that fall within each polygon on another feature class, and then update a COUNT field with the new value. I can preform the selection and creating a new layer from the selection via ArcPy but I cannot figure out how to count the points within the polygon via ArcPy. I tried
import arcpy
try:
#select all trip hazards not marked 'Closed'
arcpy.SelectLayerByAttribute_management ("Sidewalk_Trip_Hazards", "NEW_SELECTION", "\"Status\" <> \'Closed\'")
#make layer of selected hazards
arcpy.MakeFeatureLayer_management("Sidewalk_Trip_Hazards","notClosedHazards")
#spatially join points to hexbins
arcpy.SpatialJoin_analysis("notClosedHazards", "LaytonHexBins", "in_memory/SpatialJoin")
#summarize points based off of HexID
arcpy.Statistics_analysis("in_memory/SpatialJoin", "in_memory/SummarizedTable", [["HexID", "Count"]])
except:
print(arcpy.GetMessages())
Is there a way via ArcPy to do a points in polygon count?