Pitney Bowes
MapInfo Pro™ Monthly Journal
Easy Tip: Using different color labels in a layer

Piyush Mahajan, Senior Data Specialist, Data Development, Noida This is a technique to differentiate labels according to underlying data. Depending on the data, one of two different colors will be applied to the labels.
In this example we will assign a red label color for all states with a population of more than 10,000,000 within table “USA” and the rest of the labels are assigned a black color.

Solution

This can be easily done if we separate the layer into two, overlay them and set their respective label and layer properties. For the first step we need to query the data.

Perform following query and set its alias name

Query required records
Figure 1: Query required records

Open a Map window for main table and the query table. Enable the Automatic Labels option for both the layers. At this point all of the labels have same properties.

Map window with main and query layer
Figure 2: Map window with main and query layer

Now open the Layer Properties dialog for the USA_pop (the query) and set the label display color to red (Figure 3). Then set its label fit and density to “Try other Positions” under the Labeling Rules tab (Figure 4). This setting allows MapInfo Pro to use an algorithm to fit more labels on the map.

Set label display properties for query layer
Figure 3: Set label display properties for query layer

Set label rules for query layer
Figure 4: Set label rules for query layer

Now set the Label Fit and Density labeling rules for the USA layer (the main table) to Discard Label. This setting will discard the main table’s label wherever it overlaps with the label from the query table.

Set label rules for main layer
Figure 5: Set label rules for main layer

Additionally, set the label priority so that the Query layer labels are always viewable. For this, right click on the map in the Workspace Explorer (or Layer Control). See figure 6. Move the query table so that it is above the main table (Figure 7). This means the labels from the query are a higher priority than those of the main table.

Set label priority
Figure 6: Set label priority

Set label priority
Figure 7: Set label priority

And here is the final output

Desired output
Figure 8: Desired output

The techniques in this article, including setting label priorities, using an SQL query as a temporary layer in your map and setting alias names for query tables for better identification have many other uses. Be sure to keep these in mind as you use MapInfo Pro.

To learn more about the SQL Select capabilities, check out the “Be the Query Ninja” section of this journal. Here is a link to a series of articles: http://web.pb.com/mapinfopro-archive/query-ninja/

For additional labeling techniques that use expressions, check out this article: http://web.pb.com/mapinfopro-jan-2014/Advanced-Tip-Using-Expressions-For-Labelling/

And finally, for a very advanced method of labeling your maps through the use of conditions, here is an article that might interest you. http://web.pb.com/mapinfopro-jun-2012/Advanced-Tip-Conditional-Labels/

Article by Piyush Mahajan, Data Development, Noida
When not writing articles for the MapInfo Professional journal, Piyush loves to explore ways to innovate with diverse geospatial data and its utilization, is learning life coaching skills, and enjoys cooking.