# Create the Geoprocessor object import arcpy, sys, os from xml.etree.ElementTree import ElementTree from arcpy import env # Get input parameters ##env.workspace = arcpy.GetParameterAsText(0) ##xmlfile = arcpy.GetParameterAsText(1) ##outfile = arcpy.GetParameterAsText(2) env.overwriteOutput = True ##AGSHOME = arcpy.GetInstallInfo("Desktop")["InstallDir"] ##translatorpath = AGSHOME + r"Metadata\Translator\ARCGIS2FGDC.xml" #Output file ##outfile=open(outfile,'w') #Dataset list function # list any standalone feature classes env.workspace = r"C:\projects\Vicinity.gdb" AGSHOME = arcpy.GetInstallInfo("Desktop")["InstallDir"] translatorpath = AGSHOME + r"Metadata\Translator\ARCGIS2FGDC.xml" fcList = arcpy.ListFeatureClasses() fcList.sort() for fc in fcList: fcname = str(fc) ## outfile.write(fcname + "\n" + ",") print fc xmlfile = r"C:\projects\Testing\ " + fcname + ".xml" arcpy.UpgradeMetadata_conversion (fc, "ESRIISO_TO_ARCGIS") arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) tree = ElementTree() tree.parse(xmlfile) spot = tree.find("abstract") if spot: # if spot is True (not None) print spot.text else: print "No Abstract" spot = tree.find("purpose") if spot: # if spot is True (not None) print spot.text else: print "No Summary" spot = tree.find("datacred") if spot: # if spot is True (not None) print spot.text else: print "No Credits" # list feature datasets datasetList = arcpy.ListDatasets("","Feature") datasetList.sort() for dataset in datasetList: print dataset # list feature classes inside the dataset arcpy.env.workspace = dataset fcList = arcpy.ListFeatureClasses() fcList.sort() for fc in fcList: print " " + fc arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) tree = ElementTree() tree.parse(xmlfile) spot = tree.find("descript/abstract") if spot: # if spot is True (not None) print " " + spot.text else: print " No abstract"
relevant resources:
What is the Metadata module—ArcGIS Pro | Documentation
arcpy-metadata · PyPI
GitHub - ucd-cws/arcpy_metadata: Python metadata editing classes for ArcGIS feature classes
using arcpy.da.walk to inventory data and export metadata to csv
Python Errors in IDLE when processing metadata
arcpy - Creating table containing all filenames (and possibly metadata) in File Geodatabase? - Geographic Information Sy…
Access and update map and layer metadata (arcpy.mp)
python - updating metadata for feature classes programatically using arcpy - Stack Overflow
Edit metadata for many ArcGIS items—ArcMap | Documentation
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.