arcpy提取线段/道路起点,终点

# encoding: utf-8
import arcpy
data=r”D:\删减后的道路网\delbjroad.shp”
ls=[]
strout=””
with arcpy.da.SearchCursor(data, [“SHAPE@”,”ID”]) as cursor:
    for row in cursor:
        for row in cursor:
            xL, yL = row[0].firstPoint.X, row[0].firstPoint.Y
            xR, yR = row[0].lastPoint.X, row[0].lastPoint.Y
            strout+=row[1]+”,”+str(xL)+”,”+str(yL)+”\n”+row[1]+”,”+str(xR)+”,”+str(yR)+”\n”
file_handle=open(‘1.txt’,mode=’w’)
file_handle.writelines(strout.encode(‘utf-8’))
file_handle.close()

print (len(ls))
 

转载自:https://blog.csdn.net/A873054267/article/details/86004704

You may also like...

退出移动版