gpt4 book ai didi

python - 并非所有行都被添加到 SearchCursor 中的列表中

转载 作者:太空宇宙 更新时间:2023-11-03 21:07:46 24 4
gpt4 key购买 nike

with arcpy.da.SearchCursor(fc, ["LAT", "LON"]) as cursor:
for row in cursor:
print("Print rows: {} ".format(row)
xy_list = [(row[0],row[1]) for row in cursor]

print("Print list: {} ".format(xy_list))

输出:

Print rows: (44.8175669441669, -63.6431023726842) 
Print list: [(44.8175486319183, -63.6432418986223), (44.8170733108224, -63.644658488894)]

我从 SearchCursor 中提取纬度和经度以添加到列表的要素类具有三个属性。我不明白为什么没有添加所有三个坐标。

注意:我打印的“打印行:(44.8175669441669,-63.6431023726842)”的坐标不在列表中。

最佳答案

您在 for 循环中使用“光标”可迭代一次,然后在 for 主体中使用列表理解再次使用(第二次和第三次)。

看来你最终想要的是xy_list=列表(光标)

没有?

关于python - 并非所有行都被添加到 SearchCursor 中的列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55288146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com