I am trying to make a script that runs the Spatial Analyst Kriging interpolation tool on a batch of z values/fields in a point feature class. I am using the script wizard to set up the parameters, which is why you don't see the GetParameterAsText properties being defined in my code. I have run the script successfully in ArcMap 10.7.1, however I want to set symbology automatically for each Kriging output. I am failing to write the code for this and am hoping to receive some advice. Please note that I am a beginner in Python and am still learning to make customized scripts.
The issue is (despite reading help pages) I can't successfully access the output rasters (that I save with the .save() function) in my code to be used as an input for another tool.
I have been debugging lots by running the Apply Symbology From Layer tool on only individual rasters from my Kriging outputs, but the goal is to run it as a loop on all of them. This is what I have found & tried:
1. The ApplySymbologyFromLayer tool works when I run it manually in the ArcMap Python Window. This is all I have to type since the working environment is set: arcpy.ApplySymbologyFromLayer_management("Benzene", r"G:\586\FinalProject\krigingsymbology.lyr").
2. In my code, I have tried to both write the full raw path and use os.join() to access the rasters
3. The outputs I am trying to access are FGDBR rasters.
This is what I have thought of for potential solutions, but I don't want to resort to these...
1. Using the arcpy.gp.Kriging_sa instead because its parameters require a specified output name to be set, which is not the case for arcpy.sa. I could try to set the symbology property for the output parameter in the script wizard.
2. Create a whole separate tool that simply allows the Apply Symbology From Layer Tool to be run on multiple user-selected rasters.
Any help or thoughts appreciated, thank you!
This is my code (also attached below) that includes my most recent attempt to access one of the output rasters called Benzene:
This is the error:
Running script KrigingMultipleFields...
Failed script KrigingMultipleFields...
Traceback (most recent call last):
File "G:\GIS\kriging.py", line 87, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\management.py", line 6944, in ApplySymbologyFromLayer
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Layer: Dataset G:\GIS\OakGrove.gdb\Benzene does not exist or is not supported
ERROR 000968: The symbol layer does not match the input layer
Failed to execute (ApplySymbologyFromLayer).
Failed to execute (KrigingMultipleFields).
Failed at Fri Apr 24 15:39:38 2020 (Elapsed Time: 34.49 seconds)