2

I'm using ArcPy to get the current aprx, active map, then to create an empty metadata object, and populate it with values from a fGDB table, but I cant copy and save it back to the read only map metadata object.

I'm using the metadata object as documented at Metadata in the ArcGIS Pro Online Help.

m = aprx.activeMap
m.name = Title  #set the map elements name to the same as the title

# create empty metadata object and populate it with our varibles
new_md = md.Metadata()
new_md.title = 'Title'
new_md.tags = 'Tag1, Tag2'
new_md.summary = 'Summary'
new_md.description = 'Description'
new_md.credits = 'My Credits'
activemap_metadata = md.Metadata(m) #the metadata object for the active map

if activemap_metadata.isReadOnly:
        arcpy.AddMessage("the metadata object for the active map is read only")
else:
        activemap_metadata.copy(new_md)
        activemap_metadata.save()

I'm open to ideas

2 Answers 2

1

Replace the line:

activemap_metadata = md.Metadata(m)

with the line:

activemap_metadata = m.metadata

0
0

This works; @Brennan

    m = aprx.activeMap
    m.name = Title                                  
    map_metadata = m.metadata                        
    map_metadata.title = Title
    map_metadata.summary = Summary       
    map_metadata.description = Description
    map_metadata.tags = Tag
    map_metadata.credits = Credits
    map_metadata.accessConstraints = Terms
    map_metadata.save()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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