Pitney Bowes
MapInfo Pro™ Monthly Journal
Advanced Tip: Using expressions for labelling

anika Labels are one of the most useful elements of a map. The standard label functionality in MapInfo Professional allows users to label using one of the layer's columns, but layers can also be labelled using an expression. This allows users to make extra information visible on the map.

To use an expression for labelling, open the layer options dialog by double clicking on the layer to be labelled. Go to the Label Display tab, and select "Expression..." from the "Label with" drop-down menu. In MapInfo Professional version 12.0 and above, there is also a handy button next to the drop-down (as shown in figure 1 below).

properties
Figure 1: Creating a label expression

In the expression dialog, the label format can be pieced together. Many different SQL and MapBasic functions can be used to create label information. Here are a few examples.

Concatenate values

The contents of two columns can be concatenated using the + symbol. In the example shown in figure 2, the two column values are separated by a space between them. If one of the columns does not contain a value, that part of the label will remain empty.

expression
Figure 2: Name and postcode - Australian Suburbs & Localities and Postcodes products

Carriage return and case functions

The code Chr$(13) can be used to insert a carriage return in the label expression, making the second part of the label appear under the first. In the example in figure 3, the proper case function is also used to make the upper case contents of the NAME field appear in proper case.

expression
Figure 3: Name and postcode with carriage return - Australian Suburbs & Localities and Postcodes products

Complex functions

Other MapBasic functions can be used, such as using the object area function to display areas (area(obj,"sq km"), or to combine area and population values to show a population density value (shown in figure 4).

A performance tip: Keep in mind that using complicated functions may slow down your map draw time, as the values will be calculated on the fly each time a label displays. It may be preferable to create a new column and update it with the calculated value, then label using the new column instead.

expression
Figure 4: Population density of Mesh Blocks - ABS Census data 2011

Extra tipKeep Now that you are able to add extra information to labels, beware creating too much clutter on the map - too much information is just as bad as not enough! You may wish to create multiple label overrides with more label information at low zooms and less information at high zooms.

To create multiple label overrides for the same layer, right click on the layer and select "Add a Label Override". Do this again to create two label overrides that can be styled separately and can use different labelling expressions.

override

Data included in this article includes Suburbs & Localities Australia 2013.08, Postcodes Australia 2013.08 and the ABS Mesh Block data from the 2011 census. For information on MapInfo Data products visit our Web site at www.mapinfo.com/data

Article by Anika Claire, Data Engineer based in Brisbane, Australia.

When not writing articles for "The MapInfo Professional" journal, Anika enjoys making map data from around the world look nicer. Outside of work Anika loves to travel, although with a toddler and another bub on the way, this is becoming tricky. Instead, she likes to read many fantasy books and play computer games.