|
使用arcpy.SelectLayerByAttribute筛选'FUNCCLASS'为‘1’后,导出的仍然和源文件一模一样。觉得是arcpy.SelectLayerByAttribute没有选中任何数据,代码如下。出了什么问题呢?
#coding=utf-8
import arcpy
import os
# 获取当前路径
currentPath=os.getcwd()
# 遍历当前路径
files=os.listdir(currentPath)
print(files)
arcpy.env.workspace=currentPath
qry = "'FUCCLASS' = \'1\'"
for file in files:
if 'shp' in file and 'R' in file:
print(file)
temp_name = file.split('.')
arcpy.MakeFeatureLayer_management(file, temp_name[0])
arcpy.SelectLayerByAttribute_management(temp_name[0], 'NEW_SELECTION', "'FUCCLASS' = '{0}'".format('1'))
out_file = temp_name[0] + '_test3.shp'
arcpy.CopyFeatures_management(temp_name[0], out_file)
|
|