zoukankan      html  css  js  c++  java
  • Python实现Table To Point代码 分类: Python 2015-07-31 18:45 3人阅读 评论(0) 收藏

    </pre><pre name="code" class="python"><span style="font-family:KaiTi_GB2312;font-size:18px;color:#000099;"><span style="white-space:pre">	</span>ArcGIS中提供了XY To Point的工具,但是在ArcToolBox里并没有提供根据Table中的XY坐标转换为Point的工具,不利于GP工具的调用,共享一下。</span>
    </pre><pre name="code" class="python">
    <span style="color: rgb(0, 0, 153); font-family: KaiTi_GB2312;font-size:18px;">-------------------------------------</span>
    """
        Create Point Feature Class from Table
    """
    
    ################### Imports ########################
    import arcpy as ARCPY
    import arcpy.management as DM
    import arcpy.da as DA
    import ErrorUtils as ERROR
    import os as OS
    import locale as LOCALE
    LOCALE.setlocale(LOCALE.LC_ALL, '')
    
    ################ Output Field Names #################
    fieldList = ["XCoord", "YCoord"]
    
    ################### GUI Interface ###################
    def TableToPoints():
        """A Table that is include xy coordinates is used to make some points."""
    
        #get user provided inputs and outputs
        inTable = ARCPY.GetParameterAsText(0)
        outputFC = ARCPY.GetParameterAsText(1)
        
        # define a empty points feature object
        point = ARCPY.Point()
        
        # A list to hold the pointGeometry objects
        pointList = []
        
        # for each coordinate pair,populate the point object and create a new pointgeometry
        with DA.SearchCursor(inTable, fieldList) as cursors:
            for row in cursors:
                point.X = row[0]
                point.Y = row[1]
                pointGeometry = ARCPY.PointGeometry(point)
                pointList.append(pointGeometry)
                 
        # create copy of the pointGeometry objects,by using pointgeometrylist as input to the copyfeatures tool
        ARCPY.CopyFeatures_management(pointList, outputFC)
    
    if __name__ == "__main__":
        TableToPoints()
    
    --------------------欢迎来访,拒绝转载---------------------

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    git 备忘录
    模拟HTTP协议接收请求并返回信息
    微信公众号支付回调页面处理asp.net
    WinForm下判断文件和文件夹是否存在
    C# 如何判断ie版本号和获取注册表中的信息
    【转】GDI+中发生一般性错误的解决办法
    c# winform 获取当前程序运行根目录
    模拟按下某快捷键:keybd_event使用方法
    如何使用存储过程来实现分页功能
    用ASP.NET实现下载远程图片保存到本地的方法 保存抓取远程图片的方法
  • 原文地址:https://www.cnblogs.com/gishh/p/4700236.html
Copyright © 2011-2022 走看看