python 查看arcgis里面的模板文件都鏈接著啥內(nèi)容在arcgis里面輸入的代碼
我有個(gè)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
再看一共多少個(gè)輔助文件
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 # 跳過已處理的數(shù)據(jù)源 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)" # 處理地理數(shù)據(jù)庫數(shù)據(jù) else: print "FILE TYPE: Geodatabase or other format" # 檢查是否有相關(guān)的輔助文件 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
結(jié)果


浙公網(wǎng)安備 33010602011771號