arcpy读取featureClass中某一字段的所有属性值,存放到list中:(地理国情监测)
import arcpy
shppath = r"F:\\IndexData.shp"
#打印所有字段
fields = arcpy.ListFields(shppath)
for f in fields:
print f.name
#提取shp文件中的'JH字段属性值
shpfields = ['JH']
shp_List = []
shprows = arcpy.SearchCursor(shppath, shpfields)
while True:
shprow = shprows.next()
if not shprow:
break
shp_List.append(shprow.JH) #注意JH为字段名,要求为英文
print "要素个数:" + str(len(shp_List))
#逐个打印元素属性
for i in range(0, len(shp_FID)):
print shp_List[i]