• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

导出属性表字段结构

来自: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

posted on 2021-04-22 22:37  gisai  阅读(599)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3