1
我正在學習如何使用Python創建在ArcMap(10.1)中運行的腳本。 下面的代碼讓用戶選擇shapefile所在的文件夾,然後通過shapefile創建一個只包含以「landuse」開頭的shapefile的值表。如何將一行添加到Python中的值表(ArcPy)?
我不確定如何向值表中添加一行,因爲值在參數中被選中,並且該文件夾不能直接放入代碼中。請參見下面的代碼...
#imports
import sys, os, arcpy
#arguments
arcpy.env.workspace = sys.argv[1] #workspace where shapefiles are located
#populate a list of feature classes that are in the workspace
fcs = arcpy.ListFeatureClasses()
#create an ArcGIS desktop ValueTable to hold names of all input shapefiles
#one column to hold feature names
vtab = arcpy.ValueTable(1)
#create for loop to check for each feature class in feature class list
for fc in fcs:
#check the first 7 characters of feature class name == landuse
first7 = str(fc[:7])
if first7 == "landuse":
vtab.addRow() #****THIS LINE**** vtab.addRow(??)