ArcGis Python脚本——遍历输出面或折线要素的折点坐标

插个广告,制作ArcGIS的Tool工具学习下面的教程就对了:
零基础学习Python制作ArcGIS自定义工具观看链接
《零基础学习Python制作ArcGIS自定义工具》课程简介

有示例要素类如下

经过下面代码处理

 1 #遍历输出面或折线要素的折点坐标
 2 #infc:输入要素类
# code source: https://www.cnblogs.com/yzhyingcool/
# QQ:975601416
import arcpy
infc=
for row in arcpy.da.SearchCursor(infc,["OID@","SHAPE@"]):
    print("Feature{}:".format(row[0]+1))
    part_num=1
    for part in row[1]:
        print("Part{}:".format(part_num))
        pnt_num=1
        for point in part:
            if point:
                print("Point{}:{},{}".format(pnt_num,point.X,point.Y))
            else:
                print("Interior Ring:")
                pnt_num-=1
            pnt_num+=1
        part_num+=1
 

输出结果如下:

Feature1:
Part1:
Point1:307986.868613,2036382.79113
Point2:309272.746184,2038049.66947
Point3:312050.876741,2036430.41623
Point4:308224.994089,2032668.0337
Point5:307986.868613,2036382.79113
Feature2:
Part1:
Point1:315262.924831,2034551.87081
Point2:311431.750502,2029366.0271
Point3:308224.994089,2032668.0337
Point4:312050.876741,2036430.41623
Point5:315262.924831,2034551.87081
Interior Ring:
Point6:310500.415306,2033281.86827
Point7:310767.883637,2032127.53126
Point8:312278.418862,2032477.53332
Point9:312010.950532,2033631.87033
Point10:310500.415306,2033281.86827
Feature3:
Part1:
Point1:303639.755752,2046537.51978
Point2:304942.334224,2048376.45409
Point3:308005.389483,2046206.78995
Point4:306702.811011,2044367.85563
Point5:303639.755752,2046537.51978
Feature4:
Part1:
Point1:304526.111691,2037573.41852
Point2:303779.985199,2034922.28821
Point3:302208.357056,2037097.16756
Point4:304526.111691,2037573.41852
Part2:
Point1:302052.252577,2040551.30989
Point2:300597.041333,2036979.42774
Point3:298315.005519,2041113.5506
Point4:300828.552213,2045016.16257
Point5:302052.252577,2040551.30989

posted @ 2019-03-13 22:16  yzhyingcool  阅读(3966)  评论(2编辑  收藏  举报