来自:http://zhihu.geoscene.cn/article/4062

arcmap中并没有提供相关工具直接导出字段结构,这里通过以下脚本实现该功能,并将结果批量保存到txt中

#获取要素类属性表中的字段定义
import os
import arcpy
from arcpy import env

# 设置工作空间
path = r"E:\演示"
env.workspace = path
# 列出所有工作空间中所有shapefile
featureclasses = arcpy.ListFeatureClasses()
#遍历shapefile
for fc in featureclasses:
    #遍历字段
    fieldList = arcpy.ListFields(fc)
    for fld in fieldList:
        fielddefinition=("field name: " + fld.name + " ; " + " field type: " + fld.type + " ; " + " field precision: " + str(
            fld.precision) + " ; " + " field scale: " + str(fld.scale))
        #将字段定义写入txt
        with open(path+"/fd_" + fc[:-4]+".txt", "a") as fd:
            fd.write(fielddefinition+'\n')


如果安装了ArcGIS Pro,可以在ArcGIS Pro中打开数据属性表在添加字段窗口中直接复制字段然后粘贴到文本文件中

导出属性表字段结构

 

ps:也可以通过这种方法将一个表的字段结构直接添加到另一个表中

 

导出属性表字段结构



文章来源:https://blog.csdn.net/qq_41574870/article/details/105832975

相关文章:

  • 2021-11-15
  • 2022-01-27
  • 2021-11-30
  • 2021-12-05
  • 2021-10-17
  • 2021-07-04
  • 2021-09-13
  • 2021-05-21
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2022-02-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-05-17
相关资源
相似解决方案