zoukankan      html  css  js  c++  java
  • arcpy批量化操作

    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 ConnectionsConnection to wuhan.sde'
     
        # Set local parameters
        domName = "管道层级"
        gdb = r'Database ConnectionsConnection to wuhan.sde'
        inFeatures = r'Database ConnectionsConnection to wuhan.sdesss.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 Connectionswuhan.sde

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

    4. 将Domain赋值给属性

    //Assign Domain to field

    5. 为属性添加Alias

    》》

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

    2.备份线上的数据库。

    3.更新现在的数据库。

    4.上传到线上数据库。

    5.编写文档。

  • 相关阅读:
    那些年,学swift踩过的坑
    JAVA经BigDecimal圆角的解决方案及注意事项
    Jquery简介选择的
    Oracle性能优化顺序表名称来选择最有效的学习笔记
    jQuery Validate插入 reomte使用详细的说明
    公钥私人 ssh避password登陆
    Telnet,SSH1,SSH2,Telnet/SSL,Rlogin,Serial,TAPI,RAW
    mysqlbackup 还原特定的表
    OpenJDK 阅读源代码 Java 实现字节流输入类
    Android Application Thread CPU GC Operatiing and OOM Question 0603-随手笔记
  • 原文地址:https://www.cnblogs.com/2008nmj/p/14240329.html
Copyright © 2011-2022 走看看