Script to update ArcMap Layer Description and Credits from source dataset metadata

Idea created by tshindler on Apr 26, 2019
    Reviewed
    Score60
    • kroberts1_ohiodot
    • Konopkaeh
    • mag600
    • kmsagis
    • tshindler
    • epereira-esristaff

    I would like to get a pair of scripts/tools to update all the "Description" and "Credits" in the layer properties of each layer in an ArcMap MXD from the corresponding values in the source data's metadata fields. These values are inherited from the source only when the data is added to the ArcMap project, with no ongoing connection. As metadata is updated, the old or missing values in the MXD are not updated.

     

    Since the metadata for the layers on the published map service for web maps come from the MXD, not from the data layers themselves, it is essential that the current metadata be written to the MXD before publishing. Currently this must be done manually, which is a prohibitively time consuming process. Since there are potentially many layers in an MXD, it would be useful to have a script tool that would update metadata on all layers at once.

     

    In some cases, there may be values for these fields that are intentionally different in the MXD than on the source data's metadata, so the script should provide for identifying layers to be excluded from the process.

     

    Consequently there should be two scripts/tools. One to create matrix of the values for each layer in both the MXD and layer metadata, the second would do the updates.

     

    The specifications for the first script are as follows:

    • The script would have a single parameter: filename path to an MXD
    • The script would run the following steps:
    1. Create a list of all data sources referenced in the MXD
    2. Iterating through this list, write the "Layer Name", "Description", and "Credits" from the MXD layer properties.
    3. Iterating through this list, parse each source's metadata for filename and path, and "Description" and "Credits" from that source data's metadata.
    4. Create a CSV file containing the above values, with one line per layer:
      Layer name, original MXD Description, original MXD Credits, source filename and path, source file Description, source file Credits.

     

    The file created above could be used to preview the results of the update script, including potential discovery of unintended overwriting of better metadata. Such layers could be excluded from the update in the following script.

     

    The specifications for the second script are as follows:

    • The script would have two parameters: filename path to an MXD, and a comma delimited list of layers to exclude from the update. 
    • The script would run the following steps:
    1. Create a list of all data sources referenced in the MXD
    2. Iterating through this list, parse each source's metadata for "Description" and "Credits"
    3. Write those values to the corresponding layer properties in the MXD (except those layers in the exclude list).

     

    The complications to this script would be that the layer's source data could be in several formats, all of which store metadata differently. The easiest would be shapefiles and images, where it would simply parse the xml file for these values, but to be complete, it would also need to be able to extract them from a file geodatabase, a personal geodatabase, and an SDE layer. Metadata could also simply be missing. It would also need to navigate the structure of grouped layers, updating the properties of the sublayers that actually point to a data source, and leaving the group layer's properties alone.

     

    If the "exclude list" makes this too complicated, it could be omitted. Though it would be a nice thing to have, its use would be rare enough that I'd hate to have that feature discourage development of the basic functionality.

     

    Though I want this for ArcMap, where I work now, it would be useful to have it for Pro as well.