0

我正在尝试编写一个 python 脚本来确定水管网络上的流向。我已经使用这个脚本找到了每条折线的中点,现在我需要将此数据转换为点要素类,这将成为流向的箭头。

我尝试将其保存为列表,但无法将列表转换为点特征。谁能建议将中点位置保存为点要素类的方法?

#FlowArrows.py
import arcpy
#setting the environment
arcpy.env.workspace = "J:/PYTHON/Flow_Direction.gdb"
#arcpy.env.overwriteOutput = True

#Setting the containers
Pipes = r"J:\PYTHON\Flow_Direction.gdb\Pipes"
Nodes = r"J:\PYTHON\Flow_Direction.gdb\Nodes"
MidList = []

#Getting the mid point
Cursor = arcpy.SearchCursor(Pipes)
    for i in Cursor:
    Midpoint = i.shape.positionAlongLine(0.50,True).firstPoint
    MidList.append(Midpoint)

print ("done")
4

1 回答 1

2

尝试这个:

import arcpy, os
Pipes = r"H:\My Documents\GDB.gdb\Pipes"
MidList = []

Cursor = arcpy.SearchCursor(Pipes)
for i in Cursor:
    Midpoint = i.shape.positionAlongLine(0.50,True).firstPoint
    point = arcpy.Point(Midpoint.X, Midpoint.Y)
    pointGeom = arcpy.PointGeometry(point)
    MidList.append(pointGeom)

arcpy.CopyFeatures_management(MidList, os.path.join(os.path.split(Pipes)[0], "Nodes"))
于 2013-12-18T08:44:59.417 回答