# 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...") try: while row: #gp.AddMessage(row.OBJECTID) # 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()
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.