Arcpy 进度条

import sys  
reload(sys)  
sys.setdefaultencoding('utf-8') 


import arcpy
from arcpy import env
 
# Allow overwriting of output 
# 
env.overwriteOutput = 1
 
# Set current workspace 
#
inPath = arcpy.GetParameterAsText(0) 
env.workspace = inPath 

# Get a list of shapefiles in folder 
# 
fcs = arcpy.ListFeatureClasses() 

# Find the total count of shapefiles in list 
# 
fcCount = len(fcs) 

# Set the progressor 
#
arcpy.SetProgressor("step", "Copying shapefiles to geodatabase...", 0,fcCount, 1) 

# Create a file gdb to contain new feature classes 
#
arcpy.CreateFileGDB_management(env.workspace, "fgdb.gdb") 

# For each shapefile, copy to a file geodatabase 
# 
for shp in fcs: 
  # Trim the '.shp' extension 
  # 去除左边的字符
  fc = shp.rstrip(".shp") 

  # Update the progressor label for current shapefile 
  # 
  arcpy.SetProgressorLabel("Loading " + shp + "...") 

  # Copy the data 
  # 
  arcpy.CopyFeatures_management(shp, "fgdb.gdb/" + fc) 

  # Update the progressor position 
  # 
  arcpy.SetProgressorPosition()

arcpy.ResetProgressor()

进度条的使用是在ArcToolbox里面使用的,具体如何使用参见上一篇笔记Arcpy 在ArcToolbox里的使用

转载自:https://blog.csdn.net/sprintwater/article/details/37932537

You may also like...