Geographic Information Systems Asked by MikV89 on January 14, 2021
I have a script and when I run the ZonalStatisticsAsTable I get this error:
My code is:
flist = []
for file in files:
if os.path.isfile(os.path.join(root,file)) and file.endswith('.shp'):
flist.append(os.path.join(root,file))```
arcpy.env.workspace =r"Z:EMSV-057_AOIs_Reshape5_Process1_TaskAModelBuilderPruebas_MVEU_AOICAPAS"
for z in flist:
shape=z
erase=arcpy.Erase_analysis(shape,"C:OSM_coastlineswater_polygons.shp", "Tierra", cluster_tolerance="")
tZONA=arcpy.gp.ZonalStatisticsAsTable_sa(erase, "FID", raster, "Tabla", "NODATA", "ALL")
It seems you either don't have a Spatial Analyst license, or you need to enable it. How to enable extensions is described in the Help page on Using Extensions in ArcGIS.
You may also have to import and checkout the extension in your code. modified example from the documentation:
import arcpy
from arcpy.sa import *
class LicenseError(Exception):
pass
try:
if arcpy.CheckExtension("Spatial") == "Available":
arcpy.CheckOutExtension("Spatial")
else:
# raise a custom exception
raise LicenseError
#Your main code here using spatial analyst
except LicenseError:
print("Spatial Analyst license is unavailable")
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
Correct answer by Will McInnes on January 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP