Python ArcPy QueryPointAndDistance:长度不正确?

Python ArcPy QueryPointAndDistance:长度不正确?,python,arcpy,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_poin

背景:

我目前正在尝试确定点的链测长度(距离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.")
比较:

我比较了以下脚本生成的值和 根据点位置手动拆分多段线。这些值相差约4m

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

如果有人能就如何解决以下问题向我提供建议,那么
非常感谢。

如果您的数据没有定义的坐标系,您将得到几何体错误。