2
我有一個帶有多邊形的shapefile。我想找到每個的質心並將它們的xy座標放置在Easting
和Northing
字段下的屬性表中。我能找到easting
和northing
,但我無法將它放入屬性表(它表示爲空)。Python - 將值添加到字段
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"
你真的想用Python嗎?右鍵單擊屬性表中的Easting和Northing字段名稱將使您計算幾何。 – PolyGeo