我试图从包含经度和纬度值的文本文件创建一个多边形。在
以下是我目前所掌握的情况:
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}$如果你需要更多信息,请告诉我。在
以下是文本文件的屏幕截图:
你打电话给:
默认情况下,在空白处拆分。您的数据中的名称(如“Jones Tract”)中有空格。在
您可能希望在
^{pr2}$,
字符上拆分,或者使用csv
模块加载。像这样:相关问题 更多 >
编程相关推荐