1、按属性SQL选择
2、属性连接
3、自定义选择工具
很简单很实用的工具,代码如下:
# -- coding:cp936 --
# ---------------------------------------------------------------------------
# Fun : SelectFeatures
# Author: gisweis
# Date : 2020.10.25
# Email :
# Notes :
# ---------------------------------------------------------------------------
import os
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import arcpy
import string
try:
#参数1:输入的图层或表
table=arcpy.GetParameterAsText(0)
#参数2:输入的字段名称
field=arcpy.GetParameterAsText(1)
#参数2:输入的编号文本
txt=arcpy.GetParameterAsText(2)
oid_fieldname = arcpy.Describe(table).OIDFieldName
L=[]
with open(txt, "r") as f:
for line in f.readlines():
line = line.strip('\n')
if len(line) >0:
L.append(' '+field+'=' + line + ' OR')
L.append(' '+ oid_fieldname +'<0')
where=''.join(L)
arcpy.AddMessage(where)
arcpy.SelectLayerByAttribute_management(table,"NEW_SELECTION",where)
except arcpy.ExecuteError:
arcpy.GetMessages()
本文来自投稿,不代表本站立场,如若转载,请注明出处: