Select to view content in your preferred language

ArcPy - retrieving a map's metadata details

1549
2
Jump to solution
01-30-2019 11:54 AM
davedoesgis
Frequent Contributor

Short version: Can anyone tell me how to access an ArcGIS Pro map's metadata (summary, description, tags, use limitations, and credits) via code? I'd like to use ArcPy, but I'd consider any other means (Pro SDK?). The map object's documentation doesn't show any methods or properties for these.

...........................

Long version (with context, since there may be another solution):

I am trying to automate publishing an ArcGIS Pro map to a Portal hosted feature layer. The destination is my organization's ArcGIS Online account for now, but will eventually include our own Portal, once we upgrade to the newest version. The 3-step process in ArcPy of creating a .sddraft file, staging that to a .sd file, and then uploading it to my portal works pretty well, but I'm hitting a snag.

When I publish manually in Pro, the hosted feature layer in Portal has the map's summary, description, use limitations, tags, and credits. When I publish with ArcPy, only the tags come through, and the summary, description, use limitations, and credits are all blank! Is this a bug? Is there some setting to copy these over?

I can set all of these properties in my sharing draft, but my code doesn't know what values to put in there. How can I access those values to set them in the sharing draft object?

0 Kudos
1 Solution

Accepted Solutions
davedoesgis
Frequent Contributor

For this solution, now over a year ago, I ended up just configuring the metadata in a dict and setting it myself, so I did not find the "right way" to do it in that version of arcpy. 

In the latest version of Pro's arcpy and Portal/AGOL as the destination, it will publish a metadata record if you attach metadata to the source data (i.e.: in Catalog view). I find it is preferable to write actual metadata for the data source anyhow, since that should be portable as I copy the data, do geoprocessing, etc., so this is the approach I've taken. Furthermore, I have found that a few key metadata properties (tags, description, credits, use constraints) will properly publish to a hosted feature layer's item page. So that takes care of my publishing needs. The one thing to note is that the item's title will come from the name your map layer in Pro, not the metadata title, which would be a pretty typical use case for me, but night be something I occasionally wish to override. 

Using the metadata object in arcpy, I can now retrieve and edit the values. I think this was added in Pro 2.6 or 2.7. Per my comments above, our team has gone to metadata attached to the data source, and this works fine for us. The metadata functionality in arcpy is simple and so far has worked well for me, though I haven't gone super deep into it: 

https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm

The documentation at that link shows how use arcpy to read/edit the "metadata" tab values under the map layer properties and also for the map itself. I haven't tested those, but I think that would do what I was originally asking. 

 

View solution in original post

0 Kudos
2 Replies
inolaroch
Occasional Contributor

 Hi @davedoesgis,

Did find a solution ? i have the same problem!

Thank you 🙂

0 Kudos
davedoesgis
Frequent Contributor

For this solution, now over a year ago, I ended up just configuring the metadata in a dict and setting it myself, so I did not find the "right way" to do it in that version of arcpy. 

In the latest version of Pro's arcpy and Portal/AGOL as the destination, it will publish a metadata record if you attach metadata to the source data (i.e.: in Catalog view). I find it is preferable to write actual metadata for the data source anyhow, since that should be portable as I copy the data, do geoprocessing, etc., so this is the approach I've taken. Furthermore, I have found that a few key metadata properties (tags, description, credits, use constraints) will properly publish to a hosted feature layer's item page. So that takes care of my publishing needs. The one thing to note is that the item's title will come from the name your map layer in Pro, not the metadata title, which would be a pretty typical use case for me, but night be something I occasionally wish to override. 

Using the metadata object in arcpy, I can now retrieve and edit the values. I think this was added in Pro 2.6 or 2.7. Per my comments above, our team has gone to metadata attached to the data source, and this works fine for us. The metadata functionality in arcpy is simple and so far has worked well for me, though I haven't gone super deep into it: 

https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm

The documentation at that link shows how use arcpy to read/edit the "metadata" tab values under the map layer properties and also for the map itself. I haven't tested those, but I think that would do what I was originally asking. 

 

0 Kudos