Every time i run the script i got error "Error executing the grid expression, run time error, Failed to execute (Slope). " ? What is wrong with in code ?
When i run the Slope tool in ArcGIS it's give me the same error, but when i run the script in ArcGIS python Command prompt it runs successfully what is the problem, i don't understands ?
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "......."
if arcpy.CheckExtension("spatial") == "Available":
arcpy.CheckOutExtension("spatial")
outraster = arcpy.sa.Slope("elevation", "PERCENT_RISE")
outraster.save("slope_per")
arcpy.CheckInExtension("spatial")
else:
print "Spatial Analyst Liscence is not avaliable"
Solved! Go to Solution.
If you are in arcmap, go to the Customize menu, select Extensions and toggle on the spatial analyst extension. If you are running from a script, this line needs to have spatial capitalized
if arcpy.CheckExtension("spatial") == "Available": should be
if arcpy.CheckExtension("Spatial") == "Available":
from arcpy.sa import *
this line is run before the availability of the extension is made. The arcmap python command line is a different beast...try not to use it, use an external python IDE to test command line code
I get these error messages
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000824: The tool is not licensed.
Failed to execute (Slope).
every time i run the tool from arcgis and specify the folder for output result it gives me same error, but when i save it in result gdb it's run sucessfully ? what is the reason i don't understands ?
If you are in arcmap, go to the Customize menu, select Extensions and toggle on the spatial analyst extension. If you are running from a script, this line needs to have spatial capitalized
if arcpy.CheckExtension("spatial") == "Available": should be
if arcpy.CheckExtension("Spatial") == "Available":