ArcGIS 一级文件夹下所有GDB中的指定要素添加到mxd的图层中
一级文件夹下存在多个GDB,每个GDB存在多个要素类,要求对名字为frame的要素类,添加到mxd的图层中显示 如下图:
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.env.workspace = 'D:/.../一级文件夹'
wks = arcpy.ListWorkspaces(workspace_type="FileGDB")
for wk in wks:
arcpy.env.workspace = wk
features = arcpy.ListFeatureClasses('frame') # 要加载全部要素,修改此处
for f in features:
lyr = arcpy.mapping.Layer(f)
arcpy.mapping.AddLayer(df,lyr)