# Converts unselectable feature class into a selectable feature layer gp.MakeFeatureLayer(POINT,"point") gp.MakeFeatureLayer(POLYGON,"polygon") rows = gp.SearchCursor("polygon") row = rows.Next() gp.AddMessage("Calculating Points in Polgons...") # Loop through each row and count the points in each polygon record while row: # Select each record inside of the polygon feature class SelPoly = gp.SelectLayerByAttribute("polygon", "NEW_SELECTION", "\"OBJECTID\" =" + str(row.OBJECTID)) #gp.AddMessage(row.OBJECTID) # Select all the point that are inside of the polygon record SelPts = gp.SelectLayerByLocation("point", "WITHIN", SelPoly, 0, "NEW_SELECTION") # Count the points that are in each polygon GetCount = gp.GetCount_management(SelPts) # Calculate the ASSOC_PTS field with the counted points gp.CalculateField_management("polygon", "ASSOC_PTS", GetCount, "VB", "") # Move to the next row row = rows.Next()
Hello,I have been researching ways to count points in polygons and the obvious answer is to use Hawthe's Tools. I have downloaded it, and it works perfectly. My new ambitious task is to create a simple model to calculate some fields in an attribute table. I also want to put this point in polygon geoprocessing task as part of my model. Is there any way to do this? i.e. add the Hawthe tool into the model or is there another geoprocessing task that can handle this?Thanks,Mike
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.