我的github
posts - 3243,  comments - 42,  views - 158万

1. 创建Feature Class。

//新建Feature类
Create_Feature_Class()

2. Add Field。

复制代码
# Name: AddField_Example2.py
# Description: Add a pair of new fields to a table
 
# Import system modules
import arcpy
from arcpy import env
 
# Set environment settings
env.workspace = "C:/data/airport.gdb"
 
# Set local variables
inFeatures = "schools"
fieldName1 = "ref_ID"
fieldPrecision = 9
fieldAlias = "refcode"
fieldName2 = "status"
fieldLength = 10
 
# Execute AddField twice for two new fields
arcpy.AddField_management(inFeatures, fieldName1, "LONG", fieldPrecision, "", "",
                          fieldAlias, "NULLABLE")
arcpy.AddField_management(inFeatures, fieldName2, "TEXT", "", "", fieldLength)
复制代码

右键ArcToolbox查看Help里有:

3. 创建domain。

复制代码
import arcpy
 
try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    arcpy.env.workspace = r'Database Connections\Connection to wuhan.sde'
 
    # Set local parameters
    domName = "管道层级"
    gdb = r'Database Connections\Connection to wuhan.sde'
    inFeatures = r'Database Connections\Connection to wuhan.sde\sss.SDE.排水管'
    inField = "Pipe_Level"
 
    # Process: Create the coded value domain
    arcpy.CreateDomain_management(gdb, domName, "按管道层级", "SHORT", "CODED")
    
    #Store all the domain values in a dictionary with the domain code as the "key" and the 
    #domain description as the "value" (domDict[code])
    domDict = {"1":"入户线", "2": "支线", "3": "干线", \
                "4": "主干线"}
    
    # Process: Add valid material types to the domain
    #use a for loop to cycle through all the domain codes in the dictionary
    for code in domDict:        
        arcpy.AddCodedValueToDomain_management(gdb, domName, code, domDict[code])
    
    # Process: Constrain the material value of distribution mains
    arcpy.AssignDomainToField_management(inFeatures, inField, domName)
 
except Exception as err:
    print(err.args[0])
复制代码

>>在服务器端操作时上面的连接sde的字符串也可能是

Database Connections\wuhan.sde

在服务器端赋域给属性时要注意先停止服务。

 

4. 将Domain赋值给属性

//Assign Domain to field

5. 为属性添加Alias

 

》》

1.比对属性是否相同。-->Excel

2.备份线上的数据库。

3.更新现在的数据库。

4.上传到线上数据库。

5.编写文档。

posted on   XiaoNiuFeiTian  阅读(261)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2020-01-06 python detect.py
2018-01-06 斯坦福大学公开课 机器学习
2018-01-06 斯坦福大学公开课 视觉识别卷积神经网络
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示