我试图只复制我指定的要素类,而不是使用if循环复制它们。我尝试了下面的内容并执行,但不复制文件。
import arcpy
import os
arcpy.env.workspace = r'c:\arcgis\ArcTutor\ModelBuilder\GTKModelbuilder\Data\RFDA Shapefiles'
outWorkspace = r'C:\Output'
fcList = arcpy.ListFeatureClasses()
for shapefile in fcList:
if fcList == ('BedfordCalls.shp','ColleyvilleCalls.shp','HurstCalls.shp','KellersCalls.shp'):
outFeatureClass = os.path.join(outWorkspace,shapefile.strip(".shp"))
arcpy.CopyFeatures_management(shapefile, outFeatureClass)
答案 0 :(得分:0)
import arcpy
import os
arcpy.env.workspace = r'c:\Shapefile'
outWorkspace = r'C:\Output'
fcList = arcpy.ListFeatureClasses()
for shapefile in fcList:
if'BedfordCalls.shp'or'ColleyvilleCalls.shp'or'HurstCalls.shp'or'KellersCalls.shp' in fcList:
outFeatureClass = os.path.join(outWorkspace,shapefile.strip(".shp"))
arcpy.CopyFeatures_management(shapefile, outFeatureClass)
答案 1 :(得分:0)
下面应该更有效地做你想做的事情(注意早期答案的评论):
import arcpy
import os
arcpy.env.workspace = r'c:\Shapefile'
outWorkspace = r'C:\Output'
fcList = ['BedfordCalls.shp', 'ColleyvilleCalls.shp', 'HurstCalls.shp', 'KellersCalls.shp']
for shapefile in fcList:
outFeatureClass = os.path.join(outWorkspace, shapefile)
arcpy.CopyFeatures_management(shapefile, outFeatureClass)