linqy的个人博客分享 http://blog.sciencenet.cn/u/linqy

博文

Arcpy 开发工具过程说明

已有 2143 次阅读 2019-5-16 09:07 |系统分类:科研笔记| Arcpy

一、界面搭建过程的参数设置

def __init__(self):
    """Define the tool (tool name is the name of the class)."""
    self.label = "要素续编码"
    self.description = "对指定的属性字段,在给定起始编码的基础上,对没有编码的属性值进行续编码。"
    self.canRunInBackground = False

def getParameterInfo(self):
    """Define parameter definitions"""
    gdbFeatureClassPath = arcpy.Parameter(
        displayName=u"待编码的图层",
        name="gdbFeatureClassPath",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input",
        # description="选择需要编码的图层。"
    )
    fieldAttribute = arcpy.Parameter(
        displayName="待编码的属性字段",
        name="fieldAttribute",
        datatype="GPString",
        parameterType="Required",
        direction="Input",
        # description="输入需要编码的属性字段。"
    )
    startIDNum = arcpy.Parameter(
        displayName="起始编码",
        name="startIDNum",
        datatype="GPString",
        parameterType="Required",
        direction="Input",
    )
    params = [gdbFeatureClassPath, fieldAttribute, startIDNum]
    return params

三、参数的调用

def execute(self, parameters, messages):
    """The source code of the tool.
    C:\Users\Administrator\Desktop\TestData\ArcPython\testShp\Test.gdb\Line
    IDNumber      ROALN20120000000014
    """
    inFeatureClass = arcpy.Parameter[0]
    # inFeatureClass = r'C:\Users\Administrator\Desktop\TestData\ArcPython\testShp\Test.gdb\Line'
    field = arcpy.Parameter[0].valueAsText
    # field = 'IDNumber'
    startID = arcpy.Parameter[1].valueAsText
    # startID = 'ROALN20120000000014'
    doexcute(inFeatureClass, field, startID)

    return




https://blog.sciencenet.cn/blog-3134052-1179325.html

上一篇:arcengine获取面的组成点,list数组排序
下一篇:arcpy开发工具过程的参数类型说明
收藏 IP: 112.53.64.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-9-27 19:18

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部