[ArcPy Tips-1]根据指定字段的大小顺序,在另一字段中存储其序号

根据各要素某一个字段的大小,对其进行排序并在另一个字段中存储其序号。

cur=arcpy.UpdateCursor("ShapefileToEdit.shp","","","","field1 A")
# ShapefileToEdit.shp就是欲编辑的图层的名字,根据field1的大小顺序来排序,A为升序(Ascending),D为降序(Descending)
i=1
for row in cur:
  row.field2=i#序号保存在field2中
  cur.updateRow(row)
  i=i+1
del  cur,row
print "done!"
原文地址:https://www.cnblogs.com/wszhang/p/12219352.html