MapInfo Pro

 View Only
  • 1.  MapInfo Monday: Styling a Layer through an Individual Theme

    Posted 02-27-2023 03:09
    Edited by Peter Møller 03-03-2023 07:02

    Happy #mapinfomonday 

    In this post, I will show you how you can use an individual theme to apply styles to your layer based on an attribute. I'll also give a few hints about some other benefits this will give you. 

    My post a few weeks back on setting styles for new features for a layer, raised some questions from @Mark McGovern around which is the best approach when styling features in a layer: object styles saved to the table potential using the new features, using a layer override style or applying a theme of some kind to the layer.

    So let me start this article with a question: Do you have a favorite way of styling your layer? Are you using object styles saved to the table, layer overrides set at the layer level, or do you apply a theme to your layer for styling?

    Styling a Layer via an Individual Theme

    The first thing to know is that in order to use an individual theme to style your layer, you will need some attribute information. That can be based on the type of feature, "Highway", "Motorway", or "Major Road" as an example, or you can use a status field for this, "Planned", "Existing", or "To be renovated" and similar. Or you could use the year of construction or the material used for the feature. These are just a few examples.

    In my example, I have a table of cables with an attribute for status that I want to use for my style. You can see the cable layer in the map below, shown with a thin dotted red line. Currently, the Status column holds two values: "Existing" and "Planned".

    From the Map tab, I select Add Theme from the Content group. 

    In the Create Thematic Map - Step 1 of 3 dialog, I select Individual as the thematic type and a template for lines and click on the button Next >

    In the dialog Create Thematic Map - Step 2 of 3, I select the layer and the column to use.

    In the final dialog, Create Thematic Map - Step 3 of 3, I modify the style to meet my requirements, and I also change the legend slightly.

    I first click on Styles to change the styles. For each element, I set the styles in the way I want the feature represented.
    Afterward, I click on the Legend button and modify the legend slightly.
    As I could foresee the need to use this again thematic at a later stage, I decide to create a template with these settings. To do so, I click on the Save As button in the Template group at the lower right side of the dialog.
    For individual themes, it often makes sense to also check the Save Individual Value Categories option. This will link the values to the styles in the template and ensure the same style is applied to the same value the next time you use this template.
    If you forget to save the theme to a template, you can always go back and do this by modifying an existing thematic layer.
    In the dialog Create Thematic Map - Step 3 of 3, I click the OK button to apply my theme to the layer. This results in a couple of changes.
    1. The Individual Theme Layer has been added to the Layer List on top of the existing Cable layer resulting in a new style for the cables on the map.
    2. Under the added individual layer, you can see the values found in the Status column shown as the legends I modified and with their style next to them. This acts as a simple legend.
    3. A Legend window has also appeared holding the same legend details as I can see in the Layer List.
    As I have a legend in my Layer List, I decide to close the additional legend window. I also right-click the individual thematic layer in the Layer List to rename it to a friendlier name, like Cable Status.

    A few Benefits of the Indivdual Theme Worth Mentioning

    Using an individual theme to style your layer comes with a few benefits.
    First, you can use the Layer List to turn on and off individual elements of the layer. Say I wanted to only focus on the existing cable for a certain work I needed to do. From the Layer List, I can simply uncheck the Visible option for the Planned Cable value and they won't be displayed on the map.
    Secondly, as the status of the cables changes, the style will automatically change too. If I change the status of a cable from Planned to Existing, the style for that feature will also change when a refresh is forced through by for example switching back to the map window from the Info window.
    This works if I change the values one by one through the Info window, or if I perform a batch update through the dialog Update Column.

    One Thing to Watch Out for

    If you at some point add additional status values to your column, this will affect the display of the thematic layer too. First, it will show these as All Others as the layer hasn't been set up to handle these values. In the image below, I have added an additional value, To be Repaired, to a few records. Notice how they appear with a black thin line in the map and as "all others" in the Layer List.
    In order to get this new value included, you will need to recreate your thematic map, potentially using your template as this already holds the style information for the existing values. If you didn't save the template when you created the thematic layer, now is the time to create a template from your thematic layer as it will make sure the existing styles are assigned to the existing values.
    When you select your template, remember to check the options to Use Customized Legend Text and Use Individual Categories. This will use the style for the values you saved and apply your custom legends too.
    In the last step, you just need to set the style and potentially the legend for the newly added value(s).
    And now the new value is also shown in the legend and in the Layer List.
    I hope you find this useful. It is a nice way to link the values from a column to the style shown on the map.

    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data

  • 2.  RE: MapInfo Monday: Styling a Layer through an Individual Theme

    Posted 03-13-2023 19:31
    Edited by James King 03-13-2023 19:35

    Hi Peter,

    I wanted to ask a question about the way the Theme Templates are stored, particularly for the custom themes. I've recently gone through the process to update MI v2021 to build 33 (for the security update), and upon using the themes, a lot of my custom created ones are now only shown by an ID number e.g. 0089 etc rather than a named title.

    Is there a way to be able to edit these within the AppData (.thm) location? I have attempted to copy over the backed up version of the ThemeTemplate.lst, which was automatically backed up during the update process, but each time I try to load MI, it reverts back.

    Some of my templates are old but still very useful, so having the named title would be preferable.

    Below is how they are displayed in application as well as the Theme lists from the current state (right) and the backed up version (left).

    I don't mind tinkering behind the scenes, having done this with named views and Layout Templates, but having tried to use one of these and then save the template, it creates a new one rather than overwrite it, and there doesn't seem to be a "delete Theme" button or option.

    Also, many of these themes are used in various workspaces, used on a regular basis, is the Theme Name used within the workspace or does it recall the individual value and style used?

    As I can't find an option to edit these within the application, I've created this within the Ideas portal ( Maybe this could be something added to the future development of MapInfo.

    James King
    Essex County Council

  • 3.  RE: MapInfo Monday: Styling a Layer through an Individual Theme

    Posted 03-14-2023 04:16

    Hi James

    Thanks for raising this issue. I did notice this myself lately but I thought it was related to my using the Danish version of MapInfo Pro for a short while. But maybe that's not the case.

    It could sound as if it's the update process that does something unexpected. I also recently upgraded to the most recent build of MapInfo Pro v2021.1.

    When we created a single version of MapInfo Pro that supported multiple languages, we needed to ensure that all text could be translated and kept separated by language. This resulted in the new structure of the ThemeTemplate.lst file that you have found in the %AppData%\MapInfo\MapInfo\Professional\2100\ThmTmplt folder. Under each subfolder, there is a similar file for the individual languages that MapInfo Pro supports.

    The content of the file looks like this:

    Region Ranges, Five Diverging Red-Green	0047	1677505587
    Cable Status	0081	1677484884
    Template 0080	0080	1677481635
    0078	0078	1677481635
    0077	0077	1677481635
    0076	0076	1677481635
    0075	0075	1677481635
    0074	0074	1677481635
    Template 0079	0079	1677481635
    Grid Elevation (feet)	0010	875032055
    Grid Elevation (meters)	0011	875032055

    I'm not that familiar with the structure of the file but I can tell that the first two values in each line represent the name of the thematic template and the filename of the thematic template. I think the third and last value represents the thematic type; ranged, individual, and so on.

    And you are right, we do not have any tools for administrating this list of templates, such as renaming and deleting. Those options certainly could be handy.

    You can however rename the template through the ThemeTemplate.lst. You just have to ensure that MapInfo Pro isn't running when you do it. MapInfo Pro overwrites the file when you shot down MapInfo Pro so any changes done to the file will be lost.

    Please let me know if you are able to modify the file with MapInfo Pro not running.


    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data

  • 4.  RE: MapInfo Monday: Styling a Layer through an Individual Theme

    Posted 03-14-2023 10:41

    I forgot this question:

    "Also, many of these themes are used in various workspaces, used on a regular basis, is the Theme Name used within the workspace or does it recall the individual value and style used?"

    No, once applied, the template used is no longer stored in a table or in a workspace. MapInfo Pro applies the settings from the template and from then on, the styles are stored as they were read from the template.

    Changing the template will have no effect on existing themes stored in workspaces or embedded in tables.

    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data