Python实现Table To Point代码 分类: Python...

</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()
--------------------欢迎来访,拒绝转载---------------------

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

转载于:https://www.cnblogs.com/gishh/p/4700236.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值