I have the following code to calculate the number of wells within a counties layer. Right now it is giving me a total number of wells.
Where and how do I get it to loop through all the counties separately and give me that count separately?
Following this; I'd like to also calculate the well density – i.e. how many wells there are per area unit, and update the table with that value as well.
import arcpy # 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:\\Wells.shp" arcpy.MakeFeatureLayer_management(wellsLayer , "wells_lyr") countiesLayer = "C:\\COUNTIES.shp" arcpy.SelectLayerByLocation_management("wells_lyr", "INTERSECT", countiesLayer, "", "NEW_SELECTION") fieldList = "name" wellsCount = int(arcpy.GetCount_management("wells_lyr").getOutput(0)) print wellsCount