操作方法
提供的说明描述了如何打印 ArcSDE 地理数据库的要素类列表。
运行以下 Python 脚本将生成所选 SDE 地理数据库中所有要素类的列表。
打开 ArcMap。
import arcpy from arcpy import env import os # Establish connection for workspace env.workspace = r"Database Connections\Child Database" #call ListFeatureClass function fcList = arcpy.ListFeatureClasses() # Print the name of the current fc: for fc in fcList: print fc
import arcpy from arcpy import env import os # Set the workspace for the ListFeatureClass function env.workspace = r"Database Connections\Child Database 1017857.sde" # Use the ListFeatureClasses function to return a list of all fc's in the sde gdb: fcList = arcpy.ListFeatureClasses() # Write the name of the current fc in text file: txtFile = open(r"C:\data\FeatureClassList.txt","w") for fc in fcList: print fc # Write messages to a Text File txtFile.write(fc) txtFile.write (os.linesep) #close text file txtFile.close() print "done"
注: 要将此脚本转换为地理处理服务,需要替换环境工作空间参数,如下所示: env.Workspace = arcpy.GetParameterAsText(0)
从 ArcGIS 专家处获得帮助
下载 Esri 支持应用程序