I have a current script that calculates how many wells are in each county. Now, how do I update (fill in) the COUNTIES
shapefile attribute fields of 'Well_Count'
and 'Density'
import arcpy
arcpy.env.workspace = "C:\\Data"
# For each county calculate the total numbers of wells that fall into that county, and update the county table with the total count.
wellsLayer = "C:\\Data\\Wells.shp"
countiesLayer = "C:\\Data\\COUNTIES.shp"
arcpy.SpatialJoin_analysis(countiesLayer, wellsLayer, "CountyWellsJoin.shp")
with arcpy.da.SearchCursor("CountyWellsJoin.shp", ["COUNTY", "Join_Count"]) as cursor:
for row in cursor:
COUNTY = row[0]
Join_Count = row[1]
print "There are {0} wells in {1} County".format(Join_Count, COUNTY)