Obtaining message of features selected under a buffer

429
1
05-03-2020 05:08 PM
ShalinR
New Contributor II

Is there a way to print out how many features are selected under a buffer for analysis purposes using Python? I have the following script where I put an 805-meter buffer around grocery stores, and brought in a shapefile called schools and wanted to know how many schools fall within 805 meters (which is 0.5 miles) of a grocery store? When I run the script it shows me the selection of schools, but I was wondering if there was a way I can make the program print or create table full of values on how many features are selected under the buffering circle. Please let me know. Thank you!

#Creating features list for Buffer Analysis
fcList = ["schools.shp", "BroomeGroceryStores.shp"]
print(fcList)

#Selecting schools that fall within 805 meters of a grocery store
buffList = []
for fc in fcList:
    buff = arcpy.Buffer_analysis("BroomeGroceryStoress.shp", "Results/BroomeGroceryStores_buffer.shp", "805 METERS")
    buffList.append(buff)
print arcpy.GetMessages()
for buff in buffList:
    arcpy.SelectLayerByLocation_management("schools", "WITHIN", buff, 0, "ADD_TO_SELECTION")
print "Done"
0 Kudos
1 Reply