python 查看arcgis里面的模板文件都链接着啥内容在arcgis里面输入的代码
我有个arcgis里面有一堆图

在输入代码的框里面输入
import arcpy import os mxd = arcpy.mapping.MapDocument("CURRENT") layers = arcpy.mapping.ListLayers(mxd) print "=" * 60 print "ALL DATA SOURCES IN MAP DOCUMENT:" print "=" * 60 count = 0 for lyr in layers: if lyr.supports("DATASOURCE"): count += 1 print "LAYER " + str(count) + ": " + lyr.name print "SOURCE: " + lyr.dataSource print "-" * 60 print "TOTAL LAYERS FOUND: " + str(count) del mxd
再看一共多少个辅助文件
import arcpy import os mxd = arcpy.mapping.MapDocument("CURRENT") layers = arcpy.mapping.ListLayers(mxd) print "=" * 60 print "ALL DATA SOURCES AND AUXILIARY FILES" print "=" * 60 # 用于去重 processed_sources = {} for lyr in layers: if lyr.supports("DATASOURCE"): source = lyr.dataSource # 跳过已处理的数据源 if source in processed_sources: continue processed_sources[source] = True print "MAIN FILE: " + source dir_path = os.path.dirname(source) base_name = os.path.splitext(os.path.basename(source))[0] # 检测Shapefile的辅助文件 if source.lower().endswith('.shp'): print "SHAPEFILE AUXILIARY FILES:" shapefile_found = False for ext in ['.shx', '.dbf', '.prj', '.sbn', '.sbx', '.shp.xml', '.cpg']: aux_file = os.path.join(dir_path, base_name + ext) if os.path.exists(aux_file): print " - " + aux_file shapefile_found = True if not shapefile_found: print " (No auxiliary files found)" # 检测栅格文件的辅助文件 elif any(source.lower().endswith(ext) for ext in ['.tif', '.jpg', '.jpeg', '.png', '.img']): print "RASTER AUXILIARY FILES:" raster_found = False for ext in ['.tfw', '.aux.xml', '.ovr', '.rrd', '.xml']: aux_file = os.path.join(dir_path, base_name + ext) if os.path.exists(aux_file): print " - " + aux_file raster_found = True if not raster_found: print " (No auxiliary files found)" # 处理地理数据库数据 else: print "FILE TYPE: Geodatabase or other format" # 检查是否有相关的辅助文件 found_aux = False for ext in ['.aux.xml', '.xml', '.tfw']: aux_file = source + ext if os.path.exists(aux_file): print "AUXILIARY: " + aux_file found_aux = True if not found_aux: print "AUXILIARY: (Standard geodatabase format)" print "-" * 60 print "TOTAL UNIQUE DATA SOURCES: " + str(len(processed_sources)) del mxd
结果


浙公网安备 33010602011771号