Guest User

Untitled

a guest
Dec 14th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. import arcpy, os
  2. arcpy.env.workspace=r'F:SheyenneAtmospherically Corrected LandsatIndicesMainNDWImain_master'
  3. #zones to calculate stats on
  4. inpoly=r'F:SheyenneSNG_sections.shp'
  5. #where to save output files
  6. destination_path=r'F:SheyenneAtmospherically Corrected LandsatIndicesMainNDWIzonal_stats'
  7. #list of rasters to calculate statistics on
  8. rasters = arcpy.ListRasters("*water_.tif*")
  9. #start loop
  10. for raster in rasters:
  11. destination_path = os.path.join(destination_path, raster + ".dbf")
  12. arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID",raster, destination_path,"DATA","ALL")
  13.  
  14. Traceback (most recent call last):
  15.  
  16. File "<ipython-input-10-9522776a92dd>", line 1, in <module>
  17. runfile('F:/python codes/zonal_stats.py', wdir='F:/python codes')
  18.  
  19. File "C:UsersspotterAppDataLocalContinuumAnacondalibsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 685, in runfile
  20. execfile(filename, namespace)
  21.  
  22. File "C:UsersspotterAppDataLocalContinuumAnacondalibsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 71, in execfile
  23. exec(compile(scripttext, filename, 'exec'), glob, loc)
  24.  
  25. File "F:/python codes/zonal_stats.py", line 21, in <module>
  26. arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID", raster, destination_raster,"DATA","ALL")
  27.  
  28. File "C:Program Files (x86)ArcGISDesktop10.2arcpyarcpygeoprocessing_base.py", line 498, in <lambda>
  29. return lambda *args: val(*gp_fixargs(args, True))
  30.  
  31. ExecuteError: ERROR 999999: Error executing function.
  32. Create output table failed
  33. Failed to execute (ZonalStatisticsAsTable).
  34.  
  35. for raster in rasters:
  36. destination_raster = os.path.join(destination_path, raster + ".dbf")
  37. arcpy.gp.ZonalStatisticsAsTable_sa(inpoly, "OBJECTID", raster,destination_raster,"DATA","ALL")
Add Comment
Please, Sign In to add comment