I'm trying to use ArcPy to print a list of addresses of land parcels crossed by a power line. I'm using the following code to accomplish this:
# Loop through features in parcels.shp for feature in parcel: # Search cursor for address field cursor = arcpy.da.SearchCursor(parcel, 'SITUSADDR') # Loop through cursor for row in cursor: # Select features crossed by powerline.shp matchcount=arcpy.SelectLayerByLocation_management(parcel, 'CROSSED_BY_THE_OUTLINE_OF', power) # Loop through matchcount, print for i in matchcount: print((row)) # Give feedback if there are no matches if matchcount == 0: print('No features matched spatial criteria.')
The code is able to print addresses, but isn't filtering them the way I'm expecting it too. Rather than printing several addresses from 'matchcount' it prints the addresses of all parcels and seems to repeat them three times.
How can I edit this code to print only the selected features?