本帖最后由 hhxxyln 于 2024-5-24 14:49 编辑
# ---encoding:utf-8 ---
from imp import reload
import sys
reload(sys)
sys.setdefaultencoding("UTF-8")
import arcpy
inTable = arcpy.GetParameterAsText(0) # 输入
fieldvalue = arcpy.GetParameterAsText(1) # dlbm
fieldName = arcpy.GetParameterAsText(2) # 三大类
expression_1 = "converse(!"+fieldvalue+"!)"
codeblock='''
def converse(dlbm):
nyd=['0101','0102','0103','0201','0202','0203','0204','0301','0302','0303','0304','0305','0306','0307','0401','0402','0403','0404','1006','1103','1104','1104A','1107','1107A','1202','1203']
jsyd=['0603','05H1','0508','0601','0602','0701','0702','08H1','08H2','08H2A','0809','0810','0810A','09','1001','1002','1003','1004','1005','1007','1008','1009','1109','1201']
wlyd=['1105','1106','1108','1101','1102','1110','1204','1205','1206','1207']
if dlbm in nyd:
return "农用地"
elif dlbm in jsyd:
return "建设用地"
elif dlbm in wlyd:
return "未利用地"
else:
return dlbm
'''
arcpy.CalculateField_management(inTable, fieldName, expression_1, "PYTHON_9.3",codeblock)
|