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.


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
    # Deleting Selected Features
    if int(arcpy.GetCount_management(Splitline_lyr).getOutput(0)) > 0:

It runs until it split lines at vertices and give below output.

enter image description here

  • What else is in your script? How can you tell that extra lines are being selected? Please present a code snippet that works up to where you are stuck.
    – PolyGeo
    Mar 10, 2016 at 10:53
  • Question edited and example with picture is added Mar 10, 2016 at 11:29

1 Answer 1


You need to set your output coordinate system (in geoprocessing environment settings) to "Same As Display". This question was answered and discussed in more detail here:

Getting different results using Select by Location with ArcPy vs ArcMap?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.