I have two line Shape files. When I use the Select layer by location
tool to select two intersecting lines, it works fine and selects only lines which are actually intersecting.
But when I use this in Python Script by below code, it select extra lines which are not actually intersecting the Source layer line.
arcpy.SelectLayerByLocation_management("Split_Line","INTERSECT","Line")
Why this tool works different in Python script?
I am actually trying to make an offset of a given Shape line. For this I created a buffer in memory, converted it into lines, split at vertices and delete the intersecting Feature to original line.
#specifying buffer distance
buffer_feaure = "in_memory" + "\\" + "buffer" # temporary feature
line_lyr = "in_memory" + "\\" "line" # temporary feauture
#Make buffer along line
arcpy.Buffer_analysis(InputLine, buffer_feaure, "20 Meters", "LEFT", "FLAT", "ALL")
#Convert buffer to polyline
arcpy.PolygonToLine_management(buffer_feaure, line_lyr)
#Line Layer Split at vertices
Splitline_lyr = "in_memory" + "\\" "Splitline" # temporary feauture
arcpy.SplitLine_management(line_lyr,Splitline_lyr )
# Selecting layer to intersecting to the line inpput
arcpy.SelectLayerByLocation_management(Splitline_lyr,"INTERSECT",InputLine)
# Deleting Selected Features
if int(arcpy.GetCount_management(Splitline_lyr).getOutput(0)) > 0:
arcpy.DeleteFeatures_management(Splitline_lyr)
It runs until it split lines at vertices and give below output.