2

Is there a way to force the update of the Description content in the Properties/General/Description of each feature layer in an MXD?

I frequently update metadata for each feature class in ArcCatalog, but these changes are not coming through to the feature layer in MXDs.

Using ArcGIS 10.2.1

1

You can update properties of a layer in an mxd by accessing the layer in the mxd using the arcpy layer object.

Note that updating the metadata here is not updating the metadata of the dataset. I would recommend updating the dataset metadata as that will follow the dataset which is very important if you share the data with another person.

0

This is a very old question, but this answer will hopefully help people still using 10. The script below will update mxd layers with the most current metadata. It uses arcpy_metadata which is opensource. I am not associated with the developer. The script below also uses a regular expression to find and replace xml tags, with a single space, in case the abstract has been formatted.

import arcpy_metadata as md
import re
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
lyrs = arcpy.mapping.ListLayers(mxd)
for lyr in lyrs:
    if lyr.supports("DATASOURCE"):
        mds = md.MetadataEditor(lyr.dataSource)
        desc = mds.abstract
        cl = re.compile('<.*?>') # prepare to get rid of xml tags
        clt = re.sub(cl, ' ', desc) # get rid of xml tags
        lyr.description = clt
        lyr.credits = mds.credits
arcpy.RefreshTOC()
mxd.save()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.