Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In ArcGIS 10.1, I have a shapefile/layer with labels displayed on a map. Can I modify any of the formatting of the labels using Arcpy? Either directly in code or by importing style from another layer or the style manager would be fine. Specifically I want to add a halo around the text.

I have tried using arcpy.mapping.UpdateLayer with a source layer that has the label style that I want, but the only options are to update everything (including changing the source data, which I don't want) and to change symbology only (which doesn't cover the label style). Any way around this? Or another solution?

share|improve this question
This looks like a duplicate question to gis.stackexchange.com/questions/8340/… – PolyGeo Jul 25 '12 at 4:42

1 Answer

i think StyleItem (arcpy.mapping) can help you to solve your problem. it is reference of ListLayoutElements function.

Summary

Provides access to StyleItem class properties.

from the arcgis help document:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.mapping.AddLayer(df, lyrFile, "TOP")
styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.updateItem(lyrFile, styleItem)

del mxd

i hope it helps you...

share|improve this answer
I think StyleItem was put in to be able to manipulate legend items rather that layer properties, so I don't think this will work - but I hope I am wrong – PolyGeo Jul 25 '12 at 8:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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