Python License Error – 000824, Running code for Spatial Analyst or 3D Analyst

Python License Error – 000824, Running code for Spatial Analyst or 3D Analyst

I was trying to create the contour line from the PhytonGUI but failed to create it. It keep on showing me the error – 000824. Below code generates 25 m interval contour using spatial analyst but only inside ArcGis command window. It did not work outside Arcgis because I was missing important code to add. Python is a high level programming language that you can use to automate the work in the Arcgis. Here is the free course on the python.

 

import arcpy

demPath = “C:/GIS Master Program/2nd Semester/GIS 570/Lesson 1/folder/foxlake”

contourPath = “C:/GIS Master Program/2nd Semester/GIS 570/Lesson 1/homework/task1/practice/contour4.shp”

arcpy.gp.Contour_sa(demPath,contourPath,”25″,”0″,”1″)

 

And I got the below message,

Traceback (most recent call last):
File “C:/GIS Master Program/2nd Semester/GIS 570/Lesson 1/homework/test”, line 4, in <module>
arcpy.gp.Contour_sa(demPath,contourPath,”25″,”0″,”1″)
File “C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py”, line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000824: The tool is not licensed.
Failed to execute (Contour).

So it was the Error 000824

After doing so much Google search finally found the answer that we have turn on extension within the code. So to turn on spatial Analyst code will be

gp.CheckOutExtension(“Spatial”)

Finally code that did run is.

# The following code will create 25 metres contour from Foxlake Dem

import arcpy, arcinfo

arcpy.CheckOutExtension(“spatial”)

demPath = “C:/GIS Master Program/2nd Semester/GIS 570/Lesson 1/folder/foxlake”

contourPath = “C:/GIS Master Program/2nd Semester/GIS 570/Lesson 1/homework/task1/practice/contour4.shp”

arcpy.gp.Contour_sa(demPath,contourPath,”25″,”0″,”1″)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu