我已经“借用”了一些python代码来帮助我做到这一点但是,我很难得到我想要的东西。我试图获得几个多边形的顶点的XY坐标。我希望能够知道每个顶点属于哪个多边形,并希望每个顶点都在一条线上。拥有顶点ID也是一件好事。下面的代码让我接近,但它为多边形写了一行然后给我一个单独的行上的每个顶点,我不知道如何获取顶点ID。
import arcpy, os, csv
from arcpy import env
fc = "Z:/VHF/MyShapefile.shp"
csv = open("Z:/VHF/UECAVerticesFinal.csv", "w")
#with arcpy.da.SearchCursor(fc, ("OID@", 'PARCELID','UECA', "SHAPE@X","SHAPE@Y")) as cursor:
with arcpy.da.SearchCursor(fc, ("OID@", 'PARCELID','UECA', "SHAPE@")) as cursor:
for row in cursor:
# partnum = 0 taken out because it writes the same vertex for every poly
#
for part in row[3]:
# for row in cursor:
# print ("{0}, {1}, {2}, {3}".format(row[0], row[1], row[2], row[3]))
csv.write("{0},{1},{2}\n".format(row[0],row[1], row[2]))
# print ("{0},{1},{2}\n".format(row[0],row[1], row[2]))
for vertex in part:
# print(", , , {0},{1}\n".format(vertex.X, vertex.Y))
csv.write(", , , {0},{1}\n".format(vertex.X, vertex.Y))
# partnum +=1 see line 10
#
csv.close()
答案 0 :(得分:0)
这段代码可以做你想要的,使用OBJECTID来识别每个多边形:
with arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]) as cursor:
for row in cursor:
for part in row[1]:
for vertex in part:
csv.write("{0},{1},{2},{3}".format(row[0], vertex.ID, vertex.X, vertex.Y)

至于获取顶点ID,我无法找到相关的文档,可能没有这样的东西。点用于构造多边形,所以你的意思是点ID吗? (这些都包含在我的答案中)。有关官方解释,请参阅http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000006t000000。