Posts Tagged ‘dynamic label’

Multi-line text in legends

Problem: You need to create a legend with long descriptions that wrap to more than one line

Last week I read the Strange Maps slideshow essay on Slate.com, and fell in love with the last map: Soil Map of the Central Far Side of the Moon. The interesting colors make it look like an abstract painting. I stared at it appreciatively for only a little while before I began to wonder what each shade represented.

This map is available from the USGS at http://astrogeology.usgs.gov/Projects/PlanetaryMapping/DIGGEOL/moon/1047/lfar.htm. Unfortunately, the .pdf file on that web page does not have accompanying explanatory text, either. I had to dig futher down to find it, spread between two separate pages: a chart that links color swatches to soil type codes, and a list that links soil type codes to full descriptions. If all of this information was displayed together on one page as a map and legend, it would be an even more captivating piece.

Producing such a legend for an ArcMap layout is kind of tricky. ArcMap does not, by default, handle color swatches along with multiple lines of text very well. What you would envision looking something like this…

…turns out looking something like this…

….with no line breaks, and no good way to create them. I arrived at the bad-looking purple legend item in the typical way you would think to make a legend. That is, I created an attribute table field for Soil Descriptions. I called that field “Desc_” and I copied the long text descriptions into it. Then, I symbolized by category on the Desc_ field. My symbolgy definition box looked like this:

You can already start to see the problem. The Label area is truncating, and that’s where ArcMap looks to get the legend text. Yes, you can double click in this area to edit the text, but you will not be able to enter line breaks.

One solution is to convert your entire legend to graphics, ungroup it, and start editing the text boxes manually. That will work, but then you will have a static legend that doesn’t update with changes to your map. Do it a couple times, and then have to remake your entire legend when you’re asked to add new items or use a different color scheme, and you won’t want to do it again.

The solution I will describe takes more time to set up initially, but will make your life easier later on. The answer is to make ArcMap take the legend text from a special Description area instead. The Description box will let you use line breaks! But, it is not available if you symbolize by category. It is only available if you use the “draw all features using the same symbol” option. Luckily, you can mimic the effect of symbolizing by category by using multiple versions of the same layer with definition queries applied.

So, to create a legend item for the lavender “It” soil that looks like the legend item for the brown “NpNt” soil, you would follow the steps below.

1. Add the soil layer to ArcMap a second time.

2. Create a definition query on the new layer so it only displays soil type “It”.

3. Symbolize all features with the lavender color.

4. Copy the soil description text into Notepad or any text editor, and enter line breaks where you want them. Ideally you’d do this for all your soil descriptions at once so you know they’re all the same width.

5. Bring up the Layer Properties, Symbology tab. Press the Description… button and copy the text from Notepad into the Description for Legend box.

Note that you cannot create line breaks in this box by pressing the enter key! But, any line breaks you have created in Notepad will be maintained by copying and pasting.

6. Go to Layout view and insert a new legend (or right click on the one that’s there) to bring up the Legend Properties. Go to the Items tab, select your newest entry, and press the Style… button.

7. Pick one of the styles that uses “Description” instead of the default “Label” for the swatch text.

Finally, it’s looking pretty good!

You can repeat the same process for as many legend items as you need. In the end, the legend will appear and behave just as if you had symbolized by category.

If you want to take a little more time, you can make it look even better. Most people envision these sorts of legends with the swatch justified with the top of the text. You can do that if you drill down a bit within the settings. Return to step #6 where you selected the legend item and pressed the Style… button. This time, press Properties… in the Legend Item Selector box that comes up. If you go the General tab you’ll see this:

Show Descriptions should be checked because of the changes you made earlier. Press the Description Symbol… button below it. Then, press Properties… again in the Symbol Selector window that comes up. Change the Vertical Alignment to Top.

That’s shaping up into one respectable legend. 2 soils down, about 25 to go. I’m half a mind to complete it just so I can stare at that map a little longer.

Tags: , ,

Controlling the placement and properties of text labels, Part 2

This is a continuation of my post about controlling labels. In the first segment I discussed reference scale, reducing clutter, and increasing font readability.

Now we turn our attention to the most complicated features, the roads. These are tricky because some have names and others have route numbers, and it is customary to symbolize those differently. Up to now we have only changed fonts for entire feature layers. Now we are going to have to use different fonts for different types of features within the same layer.

The way to do this is by using Label Classes. Change the label method from “Label all features the same way” to “Define classes of features and label each class differently”. Then Add two new classes, one called Names and one called Numbers.

Uncheck the box to label features in the default class. Then, press the SQL Query… button next to each new class to define a query that will distinguish it from the others. In this road layer, I noticed that the “Type” field is only populated for roads with names. It is left empty for roads with route numbers. So, I set my SQL Query to “TYPE” <> ” for Names (TYPE does not equal a blank space — indicated by the single quote). Then, I set my SQL Query to “TYPE” = ” for Numbers.

Note: Depending on the field type and data entry method, you will sometimes have blank spaces in empty fields, like I have shown above. Other times those empty fields will be <Null> instead. If the fields are null you have to use different SQL queries. They would be “TYPE” IS NOT NULL and “TYPE” IS NULL, respectively. You cannot tell which type of blank you are dealing with just by looking at the attribute table. (In fact sometimes you’ll even have a mix of the two types in the same field). The only well to tell is the press the Get Unique Values button when you are building your query.

Now that I have my classes defined, I’ll set up their label fonts. For the road names, I chose plain black at 7 points, placed above the line in Curved orientation. This makes them bend nicely along with the road.

Readability tip #3:
Although it is a tempting way to fit more labels in, don’t chose a font size smaller than 6 points. Your audience will not thank you if they have to take out a magnifying glass to read your map.

For the road numbers, I chose a highway shield. You can find these in the Symbol Selector by pressing the Symbol… button. I have found that the default shields are too big for my tastes. You can change their size by pressing Properties… and going to the Advanced Text tab. Then press the Properties… button under Text Background.

Now my map is looking pretty good.

We have pretty much reached the limit of what we can control with dynamic label settings. It is time to convert to annotation and add the finishing touches. Right click on each layer and chose “Convert labels to annotation.” Because we are working with shapefiles, we’ll need to store the annotation in the map document. You can save it into your geodatabase if you are working with feature classes. (Nifty, because it makes it portable). I like to check “Convert unplaced labels to unplaced annotation” because this will generate a list that lets me know if anything I wanted to label got skipped.

Once you have finished converting to annotation, you will have a map full of graphic elements that you can modify in exactly the same way as if you had added text from the drawing toolbar. You can select them individually or as groups, drag to move them, rotate, delete, change font settings, add line breaks, change wording, etc. When you are working with your annotation, be sure you have selected the correct target layer in your drawing toolbar. (This is especially important if are adding a new label).

You can go to Annotation Groups under Data Frame Properties to turn these layers on and off if you so desire.

I’d like to call your attention to one last thing in the finished map. The label for Jonathan Dikinson Park was too big to fit on top of the park, so I turned it into a “callout” — that is, I added a line from the label to the feature it is labeling.

Readability tip #4:
Do use callouts, but only when absolutely necessary. Don’t overuse them or your map will become a maze.

To create one, go to your Advanced Text, Text Background properties, and chose a callout from the Type menu.

For more on the aesthetics of label styles and other map elements, I recommend the book Designing Better Maps by Cynthia Bewer.

Tags: , ,

Controlling the placement and properties of text labels, Part 1

Problem: ArcMap’s dynamic labels don’t look good enough on your map

Labeling is one of the most time-consuming aspects GIS work, but it can also be one of the most fun, especially if you have an artistic eye for details. Knowing a few basic tricks can reduce the pain of the process and achieve a more attractive and readable end result. I will take you through the process of producing labels for a map of the everglades in Florida.

ArcMap does a respectable job of dynamically placing labels to use as a starting point. Here is how my map looks with dynamic labels turned on with all the default settings.

It is going to need work. I recommend breaking things down into steps. First, you’ll want to tweak the dynamic label settings to get them as close as possible to how they should look in the final product. As a last step you’ll convert them to annotation in order to make final nit-picky changes to get them just right. Keeping them dynamic until the very end will save you time in the long run.

But before you do all that, you will want to set your reference scale. This is the scale at which you will display or print your map. Setting one will make life incredibly easier because symbols and labels will be optimally sized to this scale, and, most importantly, labels will stay in the same place when you zoom in and out. There is nothing more frustrating than zooming in to precisely adjust pieces of densely packed annotation only to have them all shift position when you zoom back out. Reference scale saves you from this.

To figure out what your reference scale should be, switch to layout view and change the page size and orientation to those you plant to use in your final product. Place your data frame where it should be within your map template and zoom to the extent you want to display. Now look up and notice the scale. You’ll probably want to change it to the closest round number that produces a display window you’re happy with. For me that was 1:2,000,000. Go to your data frame properties and set your reference scale to that number.

Now, start adjusting your dynamic label placement settings with the easiest (i.e. the largest, most spread apart) features first. Here that’s the parks and water bodies (lakes and marshes). Turn labels for everything else off and then pick your fonts.

Readability tip #1:
Each feature layer should have its own font, so the map reader can more easily tell which label goes with which feature.

It is common to use blue italic text with water bodies. I picked bold dark green small caps for the parks. Now, you’ll notice that The Everglades is showing up all over the place, cluttering the map. This is because ArcMap defaults to placing one label per feature part for polygons. Switching this to “remove duplicate labels” in the placement properties will help.

A lot of what you will be doing is reducing label clutter. Forcing the label to only be placed inside the polygon would help dramatically with this as well (it won’t show unless it fits). For the parks, I have reduced clutter by changing settings on the Conflict Detection tab. I increased the label buffer to 10, which forces labels to be placed further apart. I also changed the label weight to medium, which reduces the chance they will show if the labels for other features are near them.

Here’s how it looks now.

Moving on to city points. These need to stand out on top of the busy road pattern. Adding a halo in a contrasting color will help a great deal. In order to add a halo, press the Symbol… button on the Layer Properties, Labels tab. Then press the Properties… button and go the Mask tab.

1.0 is a good size is most cases. Pressing Symbol… again will let you change the halo color. Black text with a white halo is most commonly used, but you can get creative. The key is have the halo contrast both with the background and with the text. I added a light grey halo to the parks because I wanted them to show up a little better but not stand out as much as the cities. I also increased the character spacing on the parks.

Readability tip #2:
If your labels are hard to read against the background, increasing the font size isn’t the only solution. You can also:

  1. Bold the font
  2. Use all capital letters
  3. Increase the spacing between the letters
  4. Add a halo or solid rectangle background (go to Advanced Text tab for this) in a contrasting color.

Next week: Part 2. I will cover label classes, annotation and call-outs.

Tags: , ,