I am working on a script tool that will be run from a custom toolbox in ArcCatalog.
I have written everything with the inputs hardcoded into it for testing. Works great running from IDLE.
I had hoped that all I needed to do in the end was to remove the hardcoded paths and replace them for the input tool parameters:
workspace = arcpy.GetParameterAsText(0)
...
save_flag = arcpy.GetParameterAsText(10)
But when running from the script tool GUI, I'm finding several places that it fails.
I have several places where I use raster math in place raster calculator as shown below , but it errors as "not licenced" (I am sure have SA activated earlier in the script) or as "invalid parameters".
First attempt (works in IDLE, fails in script tool)
eopslopes = arcpy.Raster(masked_dem3) - (float(SinkVal) / (arcpy.Raster(euc_eop) + 1))
and shown below in context
arcpy.FeatureToRaster_conversion(eop, "OBJECTID", r"in_memory\eop_ras", dem)
inSourceData = r"in_memory\eop_ras"
slopeDist = 15
SinkVal = 1
buffdist = 10
cellSize = dem
arcpy.gp.EucDistance_sa(inSourceData, r"in_memory\eucdist_eop", "", cellSize, "", "PLANAR")
euc_eop = r"in_memory\eucdist_eop"
eopslopes = arcpy.Raster(masked_dem3) - (float(SinkVal) / (arcpy.Raster(euc_eop) + 1))
eopslopes.save(r"in_memory\eopslopes")
the above yeilds this error when run in teh script tool GUI from Caralog
PYTHON ERRORS:
Traceback info:
File "script.py", line 428, in <module>
eopslopes = arcpy.Raster(masked_dem3) - (float(SinkVal) / (arcpy.Raster(euc_eop) + 1))
Error Info:
ERROR 000824: The tool is not licensed.
Other attempts attempt (fails):
I've tried several things, that all fail. here's an example of one of those failed changes I tried to save the input rasters as raster layers :
arcpy.MakeRasterLayer_management(masked_dem3, "masked_dem3_lyr", where_clause="", envelope="", band_index="")
arcpy.MakeRasterLayer_management(euc_eop, "euc_eop_lyr", where_clause="", envelope="", band_index="")
expression = r"arcpy.Raster(masked_dem3_lyr) - (float(SinkVal) / (arcpy.Raster(euc_eop_lyr + 1))"
arcpy.gp.RasterCalculator_sa(expression, "eopslopes")
What is the correct formatting for arcpy.gp.RasterCalculator_sa(expression, "outras")?
.
.
.
In response to Jae's answer which I guess directly addressed my final bolded question above:
OK so arcpy.gp.RasterCalculator_sa() is out...but more to the spirit of my question, what then should one use in this case? my first attempt above works in IDLE, what formatting needs to be done to have it work in a script tool?