Hello,I have a script that:1) makes a buffer around the input.2) intersects the buffer with other shapefiles.3) selects the intersecting features in every shapefile. then i want to export the selected featurs (only selected featurs) from each shapefile into new shapefiles. Ive tried using arcpy.CopyFeatures_managment () and also arcpy.Select_analysis ().Both work good and give me the new shapefiles.But here is the problam: not all the shapefiles intersects with the buffer, so some of them have no selected features at all.But both arcpy.CopyFeatures_managment () and arcpy.Select_analysis () make new shapefiles for all of them, even if the original shapefile had no selected features.This means some of the new shapefiles i get are empty and have no rows in them (becouse there were no selected features to export). so why does the script export those empty shapefiles?how can i export only the selected features in the shapefiles that do intersect with the buffer? Here is an example of the code:# Import the arcgisscripting module. import arcpy import os import sys import string # Setting the Variabls. # Input Shapefile or GDB Feature class (must be Polygon). Input_Kav_Kachol = arcpy.GetParameterAsText(0) # Output Location (the folder where the resualt will be saved, can be GDB or Dataset inside GDB). Workspace = arcpy.GetParameterAsText(1) # Setting the Buffer distance around the Input Shapefile or Feature class. Distance = arcpy.GetParameterAsText(2) arcpy.env.workspace = Workspace Output_Feature_Class = "Buffer" # Creating the Buffer. result = arcpy.Buffer_analysis(Input_Kav_Kachol, Output_Feature_Class, Distance, "", "", "all") buffc = result.getOutput(0) # Setting Local variables for the Make Feature Layer tool: topo_line_shp = "W:\\Av_data\\cover_new\\mamag_mapi\\topo_line.shp" infra_line_shp = "W:\\Av_data\\cover_new\\mamag_mapi\\infra_line.shp" Output_Layer = "topo_line_Layer" Output_Layer__6_ = "infra_line_Layer" # Making temporary Feature Layers from the mamag_mapi shapefils. arcpy.MakeFeatureLayer_management(topo_line_shp, Output_Layer) arcpy.MakeFeatureLayer_management(infra_line_shp, Output_Layer__6_) # Selecting all the Lines and Polygons from mamag_mapi Shapefiles # that intersects with the buffer. arcpy.SelectLayerByLocation_management(Output_Layer, "INTERSECT", buffc, "", "NEW_SELECTION") arcpy.SelectLayerByLocation_management(Output_Layer__6_, "INTERSECT", buffc, "", "NEW_SELECTION") # Exporting the selected features to new Shapefiles. arcpy.CopyFeatures_management(Output_Layer, "topo_lines") arcpy.CopyFeatures_management(Output_Layer__6_, "infrastructure")
So Output_Layer (topo_lines) does intersect with the buffer and has selected features in it, so the new Shapefile has rows in it. But Output_Layer__6_ (infrastructure) does not intersect with the buffer. Regardles i get a new shapefile which is empty - and i dont want to get this empty shapefile at all. Will apriciate any tip 🙂