我正在学习如何使用 Python 创建在 ArcMap (10.1) 中运行的脚本。下面的代码让用户选择 shapefile 所在的文件夹,然后遍历 shapefile 以创建仅包含以“landuse”开头的那些 shapefile 的值表。
我不确定如何在值表中添加一行,因为在参数中选择了值,并且文件夹不能直接放入代码中。请参阅下面的代码...
#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(??)