My Arcpy code is not working in ArcMap 10.1 because an error with the last line:

Error 000824: The tool is not licensed.

I have all my extensions turned on, so I don't know why I would be getting this error. It seems I only need to import arcpy.sa.

Did I do this correctly, or are there other modules that should be imported for this code to work?

import arcpy, os, string, glob, sys
from arcpy import env
from arcpy.sa import *

env.workspace = r"C:\VMshared\small_example_valley8\SD2part"
outFolder = r"C:/VMshared/small_example_valley8/SDpartINT/INT"

for rasterFile in arcpy.ListRasters("*.tif"):
    oName, oExt = os.path.splitext(rasterFile + ".tif")
    outRaster = os.path.join(outFolder, oName + ".tif") 
  • 2
    If you are running the tool outside of ArcGIS session, you need to check out the license: resources.arcgis.com/en/help/main/10.1/index.html#//… – Alex Tereshenkov May 16 '15 at 19:41
  • Thanks, that did the trick. arcpy.CheckOutExtension("Spatial") – AF2k15 May 16 '15 at 19:48
  • As an aside, it's better to use the spatial analyst "map algebra" syntax instead of the undocumented arcpy.gp. i.e. outRaster = Int(Raster(rasterFile)) then outRaster.save(os.path.join(outFolder, oName + ".tif")) as that lets you combine multiple steps at once, i.e outRaster = Con(IsNull(inraster), FocalStatistics(inraster)) similar to the syntax you would use in the raster calculator which is not meant to be used in scripting. – user2856 May 18 '15 at 2:26
  • Geoprocessing error codes are documented, for 000824 see resources.arcgis.com/en/help/main/10.2/index.html#//… – DWynne May 21 '15 at 1:54

If you are running the tool outside of ArcGIS session, in Python (or when in the Python window and the extension has not already been enabled), you will need to check out an ArcGIS Spatial Analyst extension license before running a tool.

You do it with:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.