Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy, os
- arcpy.env.workspace=r'F:SheyenneAtmospherically Corrected LandsatIndicesMainNDWImain_master'
- #zones to calculate stats on
- inpoly=r'F:SheyenneSNG_sections.shp'
- #where to save output files
- destination_path=r'F:SheyenneAtmospherically Corrected LandsatIndicesMainNDWIzonal_stats'
- #list of rasters to calculate statistics on
- rasters = arcpy.ListRasters("*water_.tif*")
- #start loop
- for raster in rasters:
- destination_path = os.path.join(destination_path, raster + ".dbf")
- arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID",raster, destination_path,"DATA","ALL")
- Traceback (most recent call last):
- File "<ipython-input-10-9522776a92dd>", line 1, in <module>
- runfile('F:/python codes/zonal_stats.py', wdir='F:/python codes')
- File "C:UsersspotterAppDataLocalContinuumAnacondalibsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 685, in runfile
- execfile(filename, namespace)
- File "C:UsersspotterAppDataLocalContinuumAnacondalibsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 71, in execfile
- exec(compile(scripttext, filename, 'exec'), glob, loc)
- File "F:/python codes/zonal_stats.py", line 21, in <module>
- arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID", raster, destination_raster,"DATA","ALL")
- File "C:Program Files (x86)ArcGISDesktop10.2arcpyarcpygeoprocessing_base.py", line 498, in <lambda>
- return lambda *args: val(*gp_fixargs(args, True))
- ExecuteError: ERROR 999999: Error executing function.
- Create output table failed
- Failed to execute (ZonalStatisticsAsTable).
- for raster in rasters:
- destination_raster = os.path.join(destination_path, raster + ".dbf")
- arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID", raster,destination_raster,"DATA","ALL")
Add Comment
Please, Sign In to add comment