HowTo:  Print the list of feature classes for an ArcSDE geodatabase

相关信息
Article ID: 40036
Software:
ArcSDE 10, 10.1
Platforms:
Windows XP, Server 2003, Vista, Server 2008, Windows 7

问题描述
Instructions provided describe how to print a list of feature classes for an ArcSDE geodatabase.
已邀请:

易智瑞技术支持

赞同来自:

解决方案
Running the following Python script produces a list of all of the feature classes from the chosen SDE geodatabase.
  1. Open ArcMap.
  2. Click the Python window button.
  3. Edit the script below. Select either the name of the SDE connection file or the location of geodatabase connection. Use ## to comment out the section not used.
    import arcpy from arcpy import env import os # Establish connection for workspace env.workspace = r"Database Connections\Child Database"#call ListFeatureClass functionfcList = arcpy.ListFeatureClasses()# Print the name of the current fc:for fc in fcList:    print fc
  4. There are two ways to input the database workspace into the Python script: •Provide the location of the database connection path for geodatabase. Copy the path from the ArcCatalog Window. 
    Provide the file name of the SDE connection path of geodatabase. Right-click the selected data connection, click Properties and on the General tab, extract the path from the Name field. Copy the path from the ArcCatalog Window.
  5. Paste the path copied above into the Python script. 
  6. Paste the entire script above in the Python window in ArcMap and press Enter. The list of ArcSDE feature classes is displayed.
  7. To print the ArcSDE feature classes to a file, see code below:
    import arcpy from arcpy import env import os # Set the workspace for the ListFeatureClass function env.workspace = 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 filetxtFile.close()print "done"


创建及修改时间
Created: 3/14/2012

Last Modified: 10/8/2012
原文链接
http://support.esri.com/en/kno ... 40036

要回复问题请先登录注册