Does anyone know how to modify the location of a label programmatically?

I'd like to make the labels sit directly below the symbol!

  • 2
    Do you wish to modify the location of individual labels, or to change the position preferences for a layer's labels? – Stephen Lead Jun 23 '14 at 0:09
  • 1
    I'd like to change the position preferences for a layer's labels. – user3697700 Jun 23 '14 at 1:14
  • 1
    For anyone interested in a workaround, see answer to [this question on Stackoverflow: stackoverflow.com/questions/24275705/… – GISGe Jun 23 '14 at 6:28

I've never tried this, but from the documentation it doesn't appear possible to change a layer's label positioning properties using arcpy.

The layer class provides access to that layers' labelClass - but from what I can see, this only gives the option to toggle labels on/off, change the expression, and set SQL queries. It doesn't appear to give access to the label positioning options.

You may need to resort to ArcObjects in order to access the full set of labelling properties. As the Introduction to arcpy.mapping document says:

Arcpy.mapping is not a replacement for ArcObjects but rather an alternative for the different scenarios it supports. ArcObjects is still necessary for finer-grain development and application customization, whereas arcpy.mapping is intended for automating the contents of existing map documents and layer files.

Edit: I haven't tried using ArcObjects to adjust the label placement, but it seems the ILabelEngineLayerProperties2 interface is the place to look. This interface has a property BasicOverposterLayerProperties which allows you to "specify how labels are placed relative to features."

The documentation from this point is a bit light/non-existent so you may need to do some experimentation.

| improve this answer | |
  • So how do I use ArcObjects to modify the location of the labels? – user3697700 Jun 23 '14 at 22:37
  • 3
    Can you ask that as a separate question? (Stack Exchange is designed for one question and answer per thread. People will find this thread by searching on Labelling and ArcPy - you need to start a new thread for Labelling and ArcObjects) – Stephen Lead Jun 23 '14 at 22:46
  • That is what I was asking in my original question. Your answer didn't cover it. – user3697700 Jun 24 '14 at 1:56
  • 3
    "Does anyone know how to modify the location of a label using arcpy?" – Stephen Lead Jun 24 '14 at 2:04
  • 3
    Sorry if it seems like I'm deliberately being difficult - but Stack Exchange isn't designed like other sites - it's not a discussion forum but rather a Q&A site. So - the answer to your question about labelling and ArcPy seems to be "it's not possible". You need to post a new question asking how to do this specifically in ArcObjects. The reason Stack Exchange is set up this way is to make it easier for others to find answers to their questions in the future. – Stephen Lead Jun 24 '14 at 6:33

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.