arcpy讀取featureClass中某一欄位的所有屬性值,存放到list中
阿新 • • 發佈:2021-01-16
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]