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
asked Aug 8, 2022 at 3:23
2 Answers 2
Replace the line:
activemap_metadata = md.Metadata(m)
with the line:
activemap_metadata = m.metadata
answered Aug 8, 2022 at 12:59
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()
GforGIS
3,3954 gold badges23 silver badges40 bronze badges
answered Aug 9, 2022 at 3:01
default