I wrote a geoprocessing code using arcpy that works fine, but after the last geoprocessing tool (export table to excel) won't continue to the last task (print("Done")) although table is eported to.xls. What could be the cause?
Last part of the code:
from arcpy.sa import *
ZonalStatisticsAsTable(in_zone_data = r"C:\Users\Tim\Downloads\OB\OB\OB.shp", zone_field = "OB_UIME", in_value_raster = workingDirrectory + "/extract.tif", out_table = workingDirrectory + "/TableZonal")
arcpy.conversion.TableToExcel(Input_Table = workingDirrectory + "/TableZonal", Output_Excel_File = workingDirrectory + "/zonal_precipitation.xls" )
print("Done") #this part is not executed
try defining it as a function and then call the the function.
from arcpy.sa import *
def zonal_stat():
ZonalStatisticsAsTable(in_zone_data = r"C:\Users\Tim\Downloads\OB\OB\OB.shp", zone_field = "OB_UIME", in_value_raster = workingDirrectory + "/extract.tif", out_table = workingDirrectory + "/TableZonal")
arcpy.conversion.TableToExcel(Input_Table = workingDirrectory + "/TableZonal", Output_Excel_File = workingDirrectory + "/zonal_precipitation.xls" )
return "done"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.