我試圖通過Shapefile的字段的唯一值進行循環。該領域被命名爲AGLOMERADOS,我想循環throgh他們。 一旦我有這個列表,我想開始選擇屬性我的形狀文件,併爲每個選擇創建一個shapefile。 我得到空shapefile! :( 使用看起來代碼IM是這樣的:通過循環throgh唯一屬性值創建新圖層
import os, arcpy, numpy
from arcpy import env
arcpy.env.overwriteOutput = True
def unique_values(table, field):
with arcpy.da.SearchCursor(table, [field]) as cursor:
return sorted({row[0] for row in cursor})
agloms=unique_values(r'C:\Users\gdorna\Dropbox\CIPUV\lilp\Proyecto LILP 2014 - Infraestructura\Lincoln Infra - GIS\Iterate agloms\agloms.gdb\pais','AGLOMERADO')
i=0
for lugares in agloms:
arcpy.SelectLayerByAttribute_management("pais","NEW_SELECTION",""""AGLOMERADO" = 'lugares'""")
arcpy.CopyFeatures_management('pais', "a_" + `i`)
print `lugares` + "----->" + `i`
i=i+1
名單,我應該去應該是這樣的, agloms = '布蘭卡', 'Cipolletti型', 'CONCORDIA', 'FORMOSA' ,...
然而,我的目標是= [u'BAHIA BLANCA',u'CIPOLLETTI',u'CONCORDIA',u'FORMOSA',u'GRAN CORDOBA'....]爲什麼? !?!??
謝謝!
請添加一些說明,以及。 – BlackBeard 2018-01-10 10:03:18