3

I am trying to populate the properties of a feature class in a geodatabase using arcpy. In the past I have been given geodatabases with features classes that already have their property descriptions filled in.

How do you populate the description of a feature class using ArcPy?

I cannot seem to locate the information. Below is an example of what I am trying to achieve. This feature class "Wetland Protection Area" comes from a .gdb and its description has already been populated.

enter image description here

2 Answers 2

3

The layer class in the arcpy.mapping module has the ability to read and write layer descriptions, as well as access several other properties for the layer.

There are several examples in the help page which should get you going.

I'm not sure how you'd get the different descriptions for all your layers, but supposing you have descriptions ready to go, you could do something like this:

mxd = arcpy.mapping.MapDocument(r"C:\Project\ServerData.mxd")
layer_desc = "This is an example layer description."

for lyr in arcpy.mapping.ListLayers(mxd):
    layer.description = layer_desc
2

You can set the description using the ArcPy mapping module - specifically the Layer class. The Layer class has a description property.

So, changing the Layer description would look like this:

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
layer = arcpy.mapping.ListLayers(mxd, "Wetland Protection Area", df)[0]
layer.description = "Enter your description here"

Your Answer

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

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