ArcPy QueryPointAndDistance:长度不正确?

时间:2015-03-14 15:23:26

标签: python arcpy

背景:

我目前正在尝试确定点的连锁(距离m) 沿着折线(即拟议的铁路路线)。我公司内的一位同事 协助我写了下面的剧本。

import arcpy
arcpy.env.workspace = r"C:\Some\Arb\Folder\work.gdb"

# Input variables
fc_line = arcpy.management.MakeFeatureLayer("ftr_line")
fc_pnt = arcpy.management.MakeFeatureLayer("ftr_point")

# Get line geometry - assumes only one feature in feature class
polyline = arcpy.da.SearchCursor(fc_line, "SHAPE@").next()[0]

# Loop over the point feature class
with arcpy.da.SearchCursor(fc_pnt, "SHAPE@") as cursor:
    for row in cursor:
        # Get the percentage the current point is along the line
        perc = polyline.queryPointAndDistance(row[0], True)[1]
        # Calculate the percentage distance in metres
        dist = polyline.getLength()*perc
        print("% along line: {0}%\tDistance along line: {1}m".format(round(perc*100, 2), round(dist, 2)))

print("Script complete.")

比较:

我比较了以下脚本生成的值和 根据点位置手动分割折线。这些值相差大约4米。

enter image description here

以下是沿线的第一个位置和值 由脚本确定的是871,手动确定的值是875。

enter image description here

如果有人可以就如何解决以下问题给我建议,那就是 真的很感激。

0 个答案:

没有答案
相关问题