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.
Answer
Extract 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
Glad it works, although I am struggling to understand, why it is a must do thing, when both layers are in the same projection
No comments:
Post a Comment