Labels inside polygon a set distance from boundary

462
4
Jump to solution
04-12-2023 03:40 AM
Michele
Occasional Contributor

I am using an abbreviation dictionary with my labels, however sometimes the label is too close to the polygon boundary so I'd like to set a "distance from the polygon boundary" threshold that the label will conform to or it will either decrease in size or use the abbreviation (set by the strategy order). I tried using the "measure offset from the feature geometry" but I don't see any difference. Am I doing something wrong or is there no way to do this?

0 Kudos
1 Solution

Accepted Solutions
JesseWickizer
Esri Contributor

There's not a specific Maplex setting for avoiding feature boundaries by a specified distance, but here's something you can try. If Overrun is set to 0, polygon labels will avoid overlapping the boundary. So you could add a thick stroke to your polygon features but then change the color to null so it's not actually visible. If you still want a narrow stroke to draw on the polygon features you can use multiple strokes - one that's narrow and displays on the map, and another that's thicker but invisible.

With the default symbology, the label extends near the polygon boundary:

JesseWickizer_0-1681420199788.png

 

When another stroke is added with 20pt width and no color, it causes the abbreviation strategy to activate, shortening the label:

JesseWickizer_1-1681420207032.png

 

While this works in this simple example, when other features and labels on the map are included the labeling engine may make other decisions that could place labels nearer the boundary if there's no other room. Experiment with this and see if it helps. 

View solution in original post

0 Kudos
4 Replies
JesseWickizer
Esri Contributor

There's not a specific Maplex setting for avoiding feature boundaries by a specified distance, but here's something you can try. If Overrun is set to 0, polygon labels will avoid overlapping the boundary. So you could add a thick stroke to your polygon features but then change the color to null so it's not actually visible. If you still want a narrow stroke to draw on the polygon features you can use multiple strokes - one that's narrow and displays on the map, and another that's thicker but invisible.

With the default symbology, the label extends near the polygon boundary:

JesseWickizer_0-1681420199788.png

 

When another stroke is added with 20pt width and no color, it causes the abbreviation strategy to activate, shortening the label:

JesseWickizer_1-1681420207032.png

 

While this works in this simple example, when other features and labels on the map are included the labeling engine may make other decisions that could place labels nearer the boundary if there's no other room. Experiment with this and see if it helps. 

0 Kudos
Michele
Occasional Contributor

Hmmm.  This is a good idea, but I forgot that I am using natural earth data and the boundaries for the countries are in a polyline layer and the countries are in a polygon layer, the latter containing the labels.  I tried adding a stroke to the polygon layer (with the labels/abbreviation dictionary), but didn't notice any change even though the labels were clearly overlapping the line (even with it turned on).  Can confirm that the overlap is set to zero as well.

0 Kudos
JesseWickizer
Esri Contributor

It should still work if the boundaries are in a separate layer. 

Here's a map with Natural Earth boundaries in a separate layer from the country polygons. A 0pt stroke is added to the polygon layer and most countries are labeled, some with abbreviations.

JesseWickizer_0-1681769587433.png

Then when I change the polygon's stroke to 10pt, some labels are dropped because even the abbreviation doesn't fit and others become abbreviated.

JesseWickizer_1-1681769599657.png

Do you have Never remove (place overlapping) check on by chance? That, or an Overrun Maximum > 0 would cause labels to overlap the borders despite adding a thick stroke to the polygon.

0 Kudos
Michele
Occasional Contributor

So this is really strange, but today when I created the no color stroke the labels moved away from the boundary.  I have no idea what I did differently.  I did confirm before doing it that the never remove (place overlapping) check box was not checked and the overrun maximum was zero.  Thanks for your assistance on this Jesse!!

0 Kudos