Hello, I am wondering if this is a bug or my understanding of how this tool works is incorrect. I am running the code below in the python window of ArcGIS Pro 3.1.0
gdbBuilding = r"C:\data\city.sde\buildings"
buildingLayer = "buildingLyr"
erase_features = r"C:\data\city.sde\feature_buffer200ft"
temp = arcpy.env.scratchGDB + "\\temp"
arcpy.management.MakeFeatureLayer(gdbBuilding, buildingLayer, "VERIFIED = 1", "")
arcpy.analysis.Erase(buildingLayer, erase_features, temp)
I receive the following error:
arcgisscripting.ExecuteError: ERROR 160333: The table was not found.
Failed to execute (Erase).
If I type in the code to run the erase tool, when I get to the part for the first input, the intellisense/autocomplete presents an option for the name of the new Layer that was created. If I select it and use the other parameters the same as before, it runs without issue.
If I provide a string with the same value as the feature layer name variable, it works to my surprise. Variables that point directly to a feature class also work fine.
I tested with the Buffer tool and it worked when using the feature layer name variable as an input.
Cany anyone reproduce this behavior? Should what I'm trying work?
I changed the feature class to reference a different connection file (the first was a db user with read access to the database, the new connection uses Windows authentication and the user has read/write access) and that allowed things to work. I am not sure why one worked and another failed.
Unrelated to your issue, but this line is not correct
temp = arcpy.env.scratchGDB + "\\temp"
From the Scratch GDB documentation:
The Scratch GDB environment is read-only; you cannot set the location directly.
Instead use Scratch Workspace
temp = arcpy.env.scratchWorkspace + "\\temp"
I am not setting the location of the scratchGDB, rather I am setting a variable to a path that contains the scratchGDB location. The code below would be incorrect:
arcpy.env.scratchGDB = "C:\\Temp"