I've been looking at the new metadata module that has recently been added to ArcPy and having trouble with using it outside of ArcGIS Pro.
In the documentation (Metadata—Metadata module | Documentation) there is this sample:
import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Projects\data_management.aprx")
aprx_metadata = aprx.metadata
print(aprx_metadata.title)
print(aprx_metadata.description)
This works fine in ArcGIS Pro e.g.
But when running outside of ArcGIS Pro it is not getting the metadata e.g.
This is using ArcGIS Pro 2.5.1. It seems to be okay for metadata on datasets, but not for projects, layers and maps from my testing. I'm not sure if this is a bug or if there is something else I need to be doing when executing the code outside of ArcGIS Pro?
I am running ArcGIS Pro v2.5.0, and have the exact same issue. Did you ever figure this out?
BUG-000129978: In Arcpy Metadata, the metadata stays empty (NULL) o..
BUG-000129839: Unable to access or edit the metadata in ArcGIS Pro ..
could be the issue
Ahh good find Dan, thanks. Here's to hoping it does indeed get resolved in v2.7
I'm using Pro v. 3.3.2. It looks to be fixed as of June 2024. I ran this on a Pro project in my code editor. The Nones you see are only because the metadata is missing.
import arcpy
aprx = arcpy.mp.ArcGISProject(r"pathtoAPRX\COUNTY_BOARD_A.aprx")
for m in aprx.listMaps():
for l in m.listLayers():
layer_metadata = l.metadata
nl = "\n"
try:
print(f'title: | {layer_metadata.title}')
print(f'desc: {layer_metadata.description}')
print(f'summary: {layer_metadata.summary}')
print(f'tags: {layer_metadata.tags}{nl}')
except AttributeError as e:
print(e)
title: | None
desc: None
summary: None
tags: None
'bool' object has no attribute 'title'
'bool' object has no attribute 'title'
'bool' object has no attribute 'title'
'bool' object has no attribute 'title'
'bool' object has no attribute 'title'
'bool' object has no attribute 'title'
title: | gisedit.DBO.Ref_County_Limits
desc: This boundary file has no other pupose than to represent Will County's limits. There are no attribute data besides Esri's internal fields.
summary: None
tags: None
title: | gisedit.DBO.Ref_Surrounding_Counties
desc: Surrounding County Boundaries. US Census data is included in the attribute table.
summary: None
tags: None
title: | Townships
desc:
summary: None
tags: None
title: | gisedit.DBO.Street
desc: Right-of-Way (ROW) centerlines that has the street name within the segment and located within Will County. The data entered is by some type of governmental documentation (recorded plat, ordinance, plat of dedication/vacation, etc.). This layer is continually updated by the Will County 9-1-1 GIS Department. There is a ½ mile buffer of streets outside of Will County and could be incorrect.
summary: None
tags: None
title: | CountyBoard
desc:
summary: None
tags: None