Arcpy基础入门-6、遍历
1、列出所有的要素类
import arcpy
arcpy.env.workspace = "D:\用户目录\Documents\ArcGIS\可达性分析成果.gdb"
# Use Python's built-in function len to reveal the number of feature classes
# in the workspace
fcs = arcpy.ListFeatureClasses()
fcCount = len(fcs)
for fc in fcs:
# Copy the features from the workspace to a folder
#
print fc
print fcCount
2、列出所有的数据集
import arcpy
arcpy.env.workspace = "D:\数据备份.gdb"
ds = arcpy.ListDatasets()
dsCount = len(ds)
for dataset in ds:
print dataset
print dsCount
3、列出文件下所有的文件
import arcpy
arcpy.env.workspace = "E:\KuGou"
# Use Python's built-in function len to reveal the number of feature classes
# in the workspace
files = arcpy.ListFiles()
fcCount = len(files)
for fc in files:
# Copy the features from the workspace to a folder
#
print fc
print fcCount
4、列出所有的栅格文件
import arcpy
import arcpy.sa
arcpy.env.workspace = "E:\LE71230392003097EDC00"
# Use Python's built-in function len to reveal the number of feature classes
# in the workspace
rasterlist = arcpy.ListRasters()
fcCount = len(rasterlist)
for fc in rasterlist:
# Copy the features from the workspace to a folder
#
print fc
print fcCount
转载自:https://blog.csdn.net/sprintwater/article/details/25425163