Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 多个多边形的XY坐标的CSV_Python_Coordinates_Arcgis - Fatal编程技术网

Python 多个多边形的XY坐标的CSV

Python 多个多边形的XY坐标的CSV,python,coordinates,arcgis,Python,Coordinates,Arcgis,我借用了一些python代码来帮助我做到这一点,但是,我很难得到我想要的东西。我试图得到几个多边形顶点的XY坐标。我希望能够知道每个顶点属于哪个多边形,并且希望每个顶点都位于一条直线上。有顶点ID也很好。下面的代码让我很接近,但是它为多边形写了一行,然后在一条单独的线上给了我每个顶点,我不知道如何获得顶点ID import arcpy, os, csv from arcpy import env fc = "Z:/VHF/MyShapefile.shp" csv = open("Z:/VHF/U

我借用了一些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()

上述代码是从其他代码中借用的

此代码应该执行您想要的操作,使用OBJECTID标识每个多边形:

使用arcpy.da.SearchCursorfc,[OID@,SHAPE@]作为光标: 对于光标中的行: 对于第[1]行中的零件: 对于部分顶点: csv.write{0}、{1}、{2}、{3}.formatrow[0],vertex.ID,vertex.X,vertex.Y