Arcpy为本地数据按指定要求添加字段
要求:本地FileGDB数据,包含多个FeatureClass。以某些指定字符命名开头的FeatureClass不处理,其他FeatureClass添加指定字段(USERCODE,GIS编码,Text类型,长度32),且当FeatureClass名称为ROALK时,除USERCODE字段外,再添加一个指定字段(CODE,编码,Text类型,长度32)。使用Arcpy实现。
代码:
# -*- coding:GBK -*-
import arcpy
from arcpy import env
if __name__=='__main__':
env.workspace='D:\\TestData.gdb'
workspace = env.workspace
featureClasses = arcpy.ListFeatureClasses()
for fc in featureClasses:
if fc.upper()[:3] in ['BOU','POI','TRA']:
print "continue"
else:
arcpy.AddField_management(fc,'USERCODE','TEXT','','',32,'GIS编码')
if fc=='ROALK':
arcpy.AddField_management(fc, 'CODE', 'TEXT', '', '', 32, '编码')
转载自:https://blog.csdn.net/a_dev/article/details/78200512