Point label position from field

688
9
04-05-2018 07:21 AM
Status: Under Consideration
Labels (1)
DavidMcDermott2
New Contributor III

I would like the ability to use a field to set the anchor/zone position of the label. For example, the point would have an anchor value of 7 or S which would place the label in the center under the point. 

This could also be achieved by allowing the user to set the offset from an field, e.g. x = 0 and y = -1 would place the label in the center, underneath the point.

9 Comments
RobertBorchert

I have been doing this since the day MapLex came out.  14 years or so.

I created a domain first.  Short integer

0   Dynamic

1   North

2   North East.

etc.

Then have a Label Direction Field. I default it to Zero.

Then in your labels create 9 rules for labels. One for each of the 8 directions and one for Zero

However, I quit doing it as it became inefficient and switched to using Rotate By Attribute is it is a lot more flexible. Not sure what you want above what already exists. Can you be more specific.

.

DavidMcDermott2

Ordnance Survey provide stylesheets for their MasterMap product in the form of QML, SLD and Layer files. The data contains values to determine the labels position around the point along with its rotation. The SLD and QML files work fine because GeoServer and QGIS allow every label setting to be driven by an attribute value. I think ESRI have fallen behind in this respect. The layer file rotates the label fine but it defaults to best position which means street names where "High" and "Street" are separate points look odd.

In your example, does Maplex take with integer or the text value (1 or North) to determine position or does it use both?

Does it have to a domain? 

Where and how do you set the rule?

Thanks

RobertBorchert

You don't have to use a domain. I used a domian to help eliminate numbers that are not valid.  it could be a text domain.

 I used short integer because it takes up less space.

The value 1 in the domain shows as North in the drop down. 

Conversely if you use a rotation of 360 for the label you can place it exactly at that rotation.  You would create a field, for the sake of ease I call it Label_Rotation and make it a short integer.

You set the rules for labeling up in Label Manager.  As shown below.  The SQL Query is set to only show those with a Cardinal Direction of 1.  And it only displays them to the North. There is not set rule. You can call 1 anything.

Then I set the offset to 2 as shown, and the max offset to 400% as shown. this gives it some flexibility as to how far it will place the label and try to avoid overlap with other labels. 0 (zero) I have as dynamic.  So if the cardinal direction has not been entered it will place the label dynamically.

DavidMcDermott2

Hi Robert Borchert‌,

Thanks for your response. I understand how you have done this however it won't work in my case. The feature class already has several label classes to style the text differently depending on whether it's road, place name, water etc. As far as I'm aware you can't have label sub-classes.

The option to define label style and placement properties through attribute data is something ESRI really need to consider. This would be as well as and independent from label classes. This functionality has been available in QGIS for several releases.

RobertBorchert

But you can.  It takes minor clever setting up. How many different attributes are you talking about?

 I did an experiment with labeling that I thought was pretty clever.  In my test set I had some 200 points.  I set it up so each label could have a different font, different size, different color, be rotated, be angled.  the only thing I did not solve was changing the distance from the Point. I did this before Python was a thing.  You do it using Text Formatting Tags, which have been a part of ArcGIS for quite a long time.  I set it up with attributes for each Tag.  I had a font attribute.  In it I put the Font Name.

This is the expression to change a font to Arial.  I substitute in the expression the Font Attribute. You can do the same for the size entry.

"<FNT name=""Arial"" size=""18"">" & [LABELFIELD] & "</FNT>"

You can do a search in the help for all the Formatting Tags available.

DavidMcDermott2

Ok, So i would set up 9 classes, one for each position, then set conditional formatting using the tags in the label expression. It's a little convoluted but it could work. I'll give it a go and let you know.

DavidMcDermott2

I created 9 label classes, one for each position, then use a label expression to define the colour, font and size. The problem now is the rotate property overwrites the position property. So rather than offsetting the label to the top right then rotating the text around the offset location, the position defaults to right of the point then rotates around the point geometry. I tried using the Symbol > Position > Offset X/Y but the results are inconsistent. 

What is frustrating is my desired outcome can be achieved with an annotation layer but they are not suitable for what I need. The annotation layer WILL offset to the top right then rotate the text but Maplex can't. There just need to be a check box or something to stop this behavior.

DavidMcDermott2

I have discovered that if the rotation value is set then it overwrites the placement property. This means the idea of setting up a class per position doesn't work. I have logged it as a feature enhancement request with ESRI UK. 

WendyHarrison
Status changed to: Under Consideration

Thanks David for logging this.  It's ENH-000113362 if needed for tracking purposes.

thanks

Wendy