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

I have two different layers. One layer contains features that are supposed to sit directly on top of features in the other layer.

With ArcPy I'm doing a SelectLayerByLocation with "ARE_IDENTICAL_TO" and then a "SWITCH_SELECTION" in order to find which features from layer one aren't directly on top of layer two, and then updating the geometry accordingly.

However, ArcPy is giving me different (incorrect) results than using the Select by Location in ArcMap.

Granted the feature is only 0.01 ft away from the other, but it's still not identical.

When using ArcPy, the feature above with the S is selected, but when I use Select by Location in ArcMap it's not.

layer1_fl = arcpy.MakeFeatureLayer_management(layer1, layer1 + "_fl")
layer2_fl = arcpy.MakeFeatureLayer_management(layer2, layer2 + "_fl")

arcpy.SelectLayerByLocation_management(layer1_fl, "ARE_IDENTICAL_TO", layer2_fl)


Any idea why it's acting this way?

As suggested by @FelixIP

I added arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(102726) and all worked as expected.

• XY resolution and tolerance in Environmental Settings? – FelixIP Dec 2 '15 at 0:11
• @FelixIP Didn't think of that, but I just tried setting it and it's still selecting them when it shouldn't. – ianbroad Dec 2 '15 at 0:17
• Is there any chance that you are using buffers (which use true curves in a file geodatabase) to make the selection with projection-on-the-fly in place? If so, what you think is a circle making the selection may be squashed slightly. I'm not overly strong on coordinate systems but I tracked this down once and was only able to overcome it by copying the buffer feature class out to a shapefile and back to force a vertexed polygon to be created in the file geodatabase. – PolyGeo Dec 2 '15 at 0:24
• @PolyGeo no, all the layers are in same coordinate system. In the image above, I'm simply selecting all the boxes with the S that are directly on top of the hard to see point below where all the lines converge. All features are simple point features. – ianbroad Dec 2 '15 at 0:27
• This is from help: The Select By Location tools available in the Selection menu in ArcMap, ArcScene, and ArcGlobe evaluate spatial relationship in the coordinate system of that application's display (the current data frame). For the geoprocessing tool to match this behavior (and get identical results), set output coordinate system environment to Same as Display – FelixIP Dec 2 '15 at 0:39