AnsweredAssumed Answered

Select by location not working on in_memory layer

Question asked by patrick.jurgens on Aug 15, 2013
Latest reply on Aug 15, 2013 by Hornbydd
A coworker of my produced a great model and asked me to convert it to Python for him. The python script is failing at the same point each time I try to use it.
It is unable to run the following command:
>>> arcpy.SelectLayerByLocation_management('in_memory\\mergedStreetsPolygons', "COMPLETELY_WITHIN", outputGDB + '\\mtdbStreetBuffer', "", "NEW_SELECTION")  Traceback (most recent call last):   File "<pyshell#15>", line 1, in <module>     arcpy.SelectLayerByLocation_management('in_memory\\mergedStreetsPolygons', "COMPLETELY_WITHIN", outputGDB + '\\mtdbStreetBuffer', "", "NEW_SELECTION")   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\", line 6559, in SelectLayerByLocation     raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data. Failed to execute (SelectLayerByLocation).

The "COMPLETELY_WITHIN" selection method requires that the selecting feature be of 'polygon' type, so I checked that:
>>> arcpy.Describe('in_memory\\mtdbStreetBuffer').shapeType u'Polygon'

I saved both of the layers as Feature Classes in a File GDB.
>>> arcpy.CopyFeatures_management('in_memory\\mergedStreetsPolygons', outputGDB + '\\mergedStreetsPolygon') <Result '..path\suppressed..gdb\\mergedStreetsPolygon'> >>> arcpy.CopyFeatures_management('in_memory\\mtdbStreetBuffer', outputGDB + '\\mtdbStreetBuffer') <Result '..path\suppressed..gdb\\mtdbStreetBuffer'>

*I blocked off the path to the GDB because it divulges more information about our servers than I should post on the forum.

I brought those features into ArcMap and used Arctoolbox to run the selection and it worked.
Using the python immediate window in ArcMap also worked.

So does anyone have any idea why the selection will not work 'in_memory'?
Other similar lines of code within the same script are working properly, just not this one.