我有个arcgis里面有一堆图
在输入代码的框里面输入
import arcpy import osmxd = arcpy.mapping.MapDocument("CURRENT") layers = arcpy.mapping.ListLayers(mxd)print "=" * 60 print "ALL DATA SOURCES IN MAP DOCUMENT:" print "=" * 60count = 0 for lyr in layers:if lyr.supports("DATASOURCE"):count += 1print "LAYER " + str(count) + ": " + lyr.nameprint "SOURCE: " + lyr.dataSourceprint "-" * 60print "TOTAL LAYERS FOUND: " + str(count) del mxd
再看一共多少个辅助文件
import arcpy import osmxd = 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:continueprocessed_sources[source] = Trueprint "MAIN FILE: " + sourcedir_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 = Falsefor 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_fileshapefile_found = Trueif 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 = Falsefor 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_fileraster_found = Trueif not raster_found:print " (No auxiliary files found)"# 处理地理数据库数据else:print "FILE TYPE: Geodatabase or other format"# 检查是否有相关的辅助文件found_aux = Falsefor ext in ['.aux.xml', '.xml', '.tfw']:aux_file = source + extif os.path.exists(aux_file):print "AUXILIARY: " + aux_filefound_aux = Trueif not found_aux:print "AUXILIARY: (Standard geodatabase format)"print "-" * 60print "TOTAL UNIQUE DATA SOURCES: " + str(len(processed_sources)) del mxd
结果