I need to add a Description to a Feature Class using arcpy. The feature class lives in our enterprise geodatabase.

The Feature Class does not live in an MXD file, nor will it ever for this script's purposes.

The following code works in ArcMap when applied to a layer in the Table of Contents, however, it does not persist to the dataset within the database.

layer = arcpy.mapping.Layer("layer")
layer.description = "Description of the layer"

Any ideas on how to modify the description (and other property values) of Feature Classes within Geodatabases and not MXD files?

I am on ArcGIS 10.2


To do this you'll need to update the Description within the metadata.

Unfortunately, there doesn't seem to be a real simple way to do this with arcpy. However, @Ashatz11 over on Stackoverflow documented a pretty straightforward workflow:

Updating metadata for feature classes programatically using arcpy

Also, here's a similar post on GIS SE, that's worth checking out:

Programmatically edit/update metadata in ArcGIS 10

Specifically, the post by @nicksan -

I realize this is quite a while after the question, but we just had a big need for a similar capability and ended up building a general, free, open source Python library for the purpose. You can find it at https://github.com/ucd-cws/arcpy_metadata or by running a "pip install arcpy_metadata" - documentation is still to come, but we tried to keep things relatively Pythonic.

I don't see anywhere in the examples that he updates the Description specifically, but you could always contact him and see or look through the code on Github.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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