FYI, this script has been updated to be a little more robust.
esri-python-tools/UpdateMXDMetadata.py at master · roemhildtg/esri-python-tools · GitHub
I was looking for a solution to this and eventually just wrote a script to do it. Just make a temp directory, and run this in the python console, and have fun.
############################################# # Description: Updates the description of each layer in # the current mxd. # # Useful if the metadata changes, and you want the metadata # to be reflected in the mxd layer description ############################################# import arcpy from xml.etree.ElementTree import ElementTree #set local variables dir = arcpy.GetInstallInfo("desktop")["InstallDir"] translator = dir + "Metadata/Translator/ESRI_ISO2ISO19139.xml" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] temp_path = "C:/temp" for layer in arcpy.mapping.ListLayers(mxd, "*", df): if not layer.isGroupLayer: description_text = "" path = temp_path + '/' + layer.datasetName + '.xml' print path arcpy.ExportMetadata_conversion(layer.dataSource, translator, path) dom = xml.dom.minidom.parse(path) fields = ('abstract', 'purpose', 'credit') for field in fields: tags = dom.getElementsByTagName(field) print str( len(tags) ) + ' | ' + str( tags ) if len(tags): tag_string = tags[0].getElementsByTagName('gco:CharacterString')[0].childNodes[0].nodeValue description_text = description_text + "\n\n" + field.capitalize() + ":\n" + tag_string print description_text layer.description = description_text if field == 'credit': layer.credit = tag_string
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.