现在的位置: 首页 > 综合 > 正文

arcgis python获得字段唯一值

2013年09月17日 ⁄ 综合 ⁄ 共 477字 ⁄ 字号 评论关闭

# Import native arcgisscripting module
import arcgisscripting, sys
# Create the geoprocessor object
gp = arcgisscripting.create(9.3)

# Table and field name inputs
inTable = sys.argv[1]
inField = sys.argv[2]

rows = gp.SearchCursor(inTable)
row = rows.Next()
# Create an empty list
uniqueList = []
while row:
    # If the value is not already in the list, append it
    if row.GetValue(inField) not in uniqueList:
        uniqueList.append(row.GetValue(inField))
    row = rows.Next()
# Sort the list alphanumerically   
uniqueList.sort()
print uniqueList

抱歉!评论已关闭.