VERIFIED SOLUTION i
X

Something a bit more advanced: Conditional Labeling with MapInfo Pro

UPDATED: June 27, 2017


User-added image

Something a bit more advanced - Conditional Labeling with MapInfo Pro

User-added image

MapInfo Pro does not provide a direct way to label just those records that meet a certain condition. A commonly used workaround is to create a subset (i.e. selection or query) from the table with the desired items to be labelled. The query is added to the map as its own layer and then labelled.

Note that this article does assume you understand the basics about labeling, including choosing what field to label on. If you need basics on labeling you can find info in other articles and/or video tutorials.

Conditional labeling

There is a way to do conditional labeling without creating a query. The trick here is to use a label expression that incorporates a condition within the Int() function. The expression will yield a result of zero or 1 and this result will control whether or not a label will appear for any given item in the map.

The following are some examples:

Given a field containing numeric values, the following expression will avoid labeling any value that is zero: 

Left$ ( Str$ (COLUMN_NAME ) , Int (COLUMN_NAME > 0 ) * Len ( Str$ (COLUMN_NAME ) ) ) 

The technique mentioned above can be used in different ways. The following are two more examples:

1) The following expression will label any value above 50,000.

Left$ ( Str$ (COLUMN_NAME ) , Int (COLUMN_NAME > 50000 ) * Len ( Str$ (COLUMN_NAME ) ) )

2) Given a character column containing classified data ("type" data), you could avoid the labeling of one of the types. Let's say a set of points represents different types of medical practices. The types are GPs, paediatricians, cardiologists, neurologists, etc. The following expression will label all of the different types except for GPs. 

Left$ ( Str$ (COLUMN_NAME ) , Int (COLUMN_NAME <> "GP" ) * Len ( Str$ (COLUMN_NAME ) ) )

Finally, to label only the GPs, just change the <> expression to =

Left$ ( Str$ (COLUMN_NAME ) , Int (COLUMN_NAME = "GP" ) * Len ( Str$ (COLUMN_NAME ) ) )

User-added image

Overall, these techniques are tricky expressions but they do provide a capability otherwise not available. Once you've done one or two, we're sure you'll get the hang of it!

 

Downloads

  • No Downloads