arcgis for python 如何获取线要素起点 终点坐标

python脚本,如何获取线要素起点 终点坐标?
已邀请:

yuhenry

赞同来自: 江宝骅 潘建伟 zsf 游_199

with arcpy.da.SearchCursor(lyr, ["SHAPE@"]) as lyrCur:  
for row in lyrCur:
xL, yL = row[0].firstPoint.X, row[0].firstPoint.Y
xR, yR = row[0].lastPoint.X, row[0].lastPoint.Y
注意firstPoint 和 lastPoint属性为只读!!!

宋伟凯

赞同来自:

这段代码有什么问题?setValue行出错
import arcpy
fc = r"C:\Users\songwk.songwk-PC2.000\Documents\ArcGIS\Default.gdb\GX_DSL_Intersect"
with arcpy.da.UpdateCursor(fc, ["SHAPE@","SX","SY","EX","EY"]) as cursor:
    for row in cursor:
        #print("QD:X = {0},Y = {1}",row[0].firstPoint.X,row[0].firstPoint.Y)
        #print("ZD:X = {0},Y = {1}",row[0].lastPoint.X,row[0].lastPoint.Y)
        row.setValue("SX",row[0].firstPoint.Y)
        row.setValue("SY",row[0].firstPoint.Y)
        row.setValue("EX",row[0].lastPoint.X)
        row.setValue("EY",row[0].lastPoint.Y)
        cursor.updateRow(row)
    del cursor, row

鸡毛掸子

赞同来自:

初学者,请教yuhenry,如何使用,能否具体讲解一下,谢谢。

xiaosi9524 - GISER

赞同来自:

一楼最后一行:注意firstPoint 和 lastPoint属性为只读!!!

要回复问题请先登录注册