Directions: For each county calculate the total numbers of wells that fall into that county, and update the county table with the total count. This is the code I have so far.
- The counties selected only returns 1, so I know there is an error somewhere.
- Not sure if things are in order and I am not sure if the intersect of counties and wells and the total count even happened.
import arcpy #variables CountyPath = "C:\\PythonProgramming\\Lesson 5\\Lesson5_Data\\COUNTIES.shp" WellsPath = "C:\\PythonProgramming\\Lesson 5\\Lesson5_Data\\Wells.shp" fieldList = "COUNTY" # select single counties AllCounties =  # blank list with arcpy.da.SearchCursor(CountyPath,'COUNTY') as cursor: for row in cursor: # go through each feature one by one if row.upper() not in AllCounties: # check it's not already in the list AllCounties.append(row.upper()) for COname in AllCounties: where_clause = "upper(COUNTY) = '" + COname + "'" print where_clause arcpy.MakeFeatureLayer_management (CountyPath, "county_lyr", where_clause) arcpy.MakeFeatureLayer_management (WellsPath, "wells_lyr") #use update cursor to calculate the total numbers of wells that fall into that county with arcpy.da.UpdateCursor(CountyPath, fieldList, where_clause) as cursor: for row in cursor: row = row.upper() cursor.updateRow(row) #select statement arcpy.SelectLayerByLocation_management("wells_lyr", "INTERSECT", "county_lyr", "", "NEW_SELECTION")
I am new to this.