I have parcels and a buffer around greenways. I'm trying to populate a field in the parcel fc with a '1' if the parcel intersects the buffer. I can get that fine with an update cursor and select layer by location. My problem is getting out of the cursor with all of the records rather than just those selected. Here is my code:
arcpy.management.AddField(regionParcels,"BufferParcels","SHORT")
arcpy.management.MakeFeatureLayer(regionParcels,"layerParcels")
with arcpy.da.UpdateCursor("layerParcels","BufferParcels") as cursor:
arcpy.management.SelectLayerByLocation("layerParcels",'INTERSECT',bigBuffer)
for row in cursor:
row[0] = 1
cursor.updateRow(row)
arcpy.management.SelectLayerByAttribute("layerParcels",'CLEAR_SELECTION')
arcpy.management.CopyFeatures("layerParcels",markedParcels)
With this code, every record is in the output, but they all have '1' in that field. If I drop the 'clear selection' command, I get just the selected features with the field populated, but I need the entire dataset. I've tried moving the clear command into the for loop, but that didn't work either. Any other suggestions?
SelectLayerByLocation
above thewith
.