我有一个带有多边形的 shapefile。我想找到每个的质心并将它们的 xy 坐标放入字段Easting
和Northing
. 我能够找到easting
and northing
,但我无法将它放入属性表(它显示为空)。
import arcpy
arcpy.env.workspace = folderpath
arcpy.env.overwriteOutput = True
inputRoofs = "Roof"
print "working"
table = inputRoofs
arcpy.AddField_management(inputRoofs, 'Easting', 'DOUBLE')
arcpy.AddField_management(inputRoofs, 'Northing', 'DOUBLE')
print "fields added"
roofList_x = []
roofList_y = []
roof_cursor = arcpy.UpdateCursor("Roof")
for roof in roof_cursor:
roof_geom = roof.Shape
roofList_x.append(roof_geom.centroid.X)
roofList_y.append(roof_geom.centroid.Y)
print roofList_x
print roofList_y
print "done"