为什么我会收到“值错误:太多值无法解包”的消息

2024-05-10 01:09:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从包含经度和纬度值的文本文件创建一个多边形。在

以下是我目前所掌握的情况:

out_path ="C:/Output"
out_name = "Shapefile.shp"
geometry_type = "POLYGON"
template = "Other.shp"
has_m = "DISABLED"
has_z = "DISABLED"
spatial_reference = arcpy.Describe("Other.shp").spatialReference
arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, template, has_m, has_z, spatial_reference)

cursor = arcpy.da.InsertCursor("Other.shp", ["SHAPE@"])
array = arcpy.Array()
point = arcpy.Point()
for line in fileinput.input(new_txt):
    point.Name, point.X, point.Y = line.split()
    line_array.add(point)
polygon = arcpy.Polygon(array)
cursor.insertRow([polygon])
fileinput.close()
del cursor 

错误是:

^{pr2}$

如果你需要更多信息,请告诉我。在

以下是文本文件的屏幕截图:

enter image description here


Tags: pathnametypelinetemplateoutarraycursor
1条回答
网友
1楼 · 发布于 2024-05-10 01:09:52

你打电话给:

line.split()

默认情况下,在空白处拆分。您的数据中的名称(如“Jones Tract”)中有空格。在

您可能希望在,字符上拆分,或者使用csv模块加载。像这样:

^{pr2}$

相关问题 更多 >