I am running a code that uses arcpy.sa.ExtractByMask but it returns:
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000824: The tool is not licensed.
Failed to execute (ExtractByMask)
I know i have spatial analyst licensed and the tool works fine within arcmap itself. Anyone ever come across this?
Edit:
arcpy.CheckExtension('Spatial')
returns 'Available'
The code I am trying to run is:
#
"""folder containing only your input rasters and nothing else"""
indir = 'D:\Sheyenne\Atmospherically Corrected Landsat\Practice_bands'
"""absolute path to your mask layer"""
mask = 'D:\Sheyenne\Sheyenne_area.shp'
"""create emply list to hold paths to input rasters"""
inrasters = []
"""populate the list inrasters with all paths to .tif in directory"""
os.chdir(indir)
for r in glob.glob('*.tif'):
inrasters.append(r)
"""iterate over all input .tif from list inrasters"""
for inraster in inrasters:
"""create a unique name for each output raster"""
outraster = inraster.replace('.tif','_clip.tif')
"""Clip each raster with it's unique name as output"""
arcpy.gp.ExtractByMask_sa('inraster','mask')
The snippet when I run the tool in arcmap is:
arcpy.gp.ExtractByMask_sa("LT50290282011268PAC01_sr_band1.tif", "sheyenne_area_poly", "D:/Sheyenne/Atmospherically Corrected Landsat/Practice_band_clip/p1")
Note that the code is using a loop to execute extract by mask for multiple images while the snippet is the tool for just 1 image.