Select to view content in your preferred language

arcpy in ArcGIS Pro - Setting a layer to have it own metadata

954
2
Jump to solution
02-08-2022 04:33 AM
HarshaPerera
Occasional Contributor

Hello,

I am trying to use arcpy in ArcGIS Pro to set properties on layers including the description and summary. I am using
the metadata object to do this. The properties get saved. However, they are not used as the layer has not been set to
have it own metadata. How do I do this in arcpy? The current code is similar to the following

layerMetadata = layer.metadata

layerMetadata.description = description
layerMetadata.summary = summary
# The following do not have an effect
# layer.metadata = layerMetadata
# layerMetadata.save()

# This saves the metadata. However the layer is not set to use it
aprx.save()

Thanks,

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
HarshaPerera
Occasional Contributor

Thanks for the reply. Unfortunately, neither of those work. I found that getting and setting the layer definition does allow this to be changed.

e.g.

      l_cim = layer.getDefinition('V2')
      l_cim.useSourceMetadata = False
      layer.setDefinition(l_cim)


However, setting the definition (even if no changes have been made to the object) cause the layer to become disconnected. I'll raise a separate post for that.

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

Metadata—ArcGIS Pro | Documentation

synchronize? upgrade?


... sort of retired...
0 Kudos
HarshaPerera
Occasional Contributor

Thanks for the reply. Unfortunately, neither of those work. I found that getting and setting the layer definition does allow this to be changed.

e.g.

      l_cim = layer.getDefinition('V2')
      l_cim.useSourceMetadata = False
      layer.setDefinition(l_cim)


However, setting the definition (even if no changes have been made to the object) cause the layer to become disconnected. I'll raise a separate post for that.

0 Kudos