MapInfo Pro

MapInfo Monday: Filtering Layers using a Thematic Map

  • 1.  MapInfo Monday: Filtering Layers using a Thematic Map

    Posted 09-28-2020 03:07
    Edited by Peter Horsbøll Møller 09-28-2020 03:13
    Happy Monday!

    Today we will be looking at filtering layers using a thematic map. Sometimes you only want to view specific elements from a table/layer on your map. How do you filter out those elements that you want to focus on?

    There are a few ways of doing it; You could use the filter option in your browser window and add the resulted filtered view to the map you. You can run a query to select the features you want and then add these to the map as a query result. And finally, you can add a theme to your layer and here use your condition to create two groups of features: those that meet your condition, and those that don't.

    One of the benefits of using the approach with the thematic map is that it will automatically get updated if you change the data. If you are using a query, you will have to rerun the query to see the changes.

    In my example, I have a table with roads where I'm only interested in the roads where the (signed) speed is less than or equal to 50 km/h. What you typically would do is create a thematic map where you group the streets into the many different speed groups. But that would give you multiple results with a variety of colors.

    If you want a more clear result, you can create this thematic map as an Individual Theme, and in the dialog Create Thematic Map - Step 2 of 3 select the layer and for Field you select Expression from the bottom of the list.In the Expression dialog shown, you need to enter a condition using this basic structure:
    Str$(IIf(condition, true_text, false_text))

    where
    - condition is an expression that your records should meet
    - true_text is the text to show for records that meet the condition
    - false_text is the text to show for records that don't meet the condition.

    The Str$() function around the IIf() function tells MapInfo Pro to treat the returned values as strings. This is needed because the IIf() function can return almost any variable type.

    In my example, the expression looks like this:
    Str$(IIF(SPEED<=50, "Less than or equal to 50 km/h", "More than 50 km/h"))

    The above shows a way to convert the real values to a friendlier version that easily can be shared with people not that familiar with the data. They can quickly see what is shown on the map. If you just use the condition as the expression, the values returned will be either True or False (1 or 0) which also would work.

    In the image below you can see the resulting map, Notice that I have used the Layer List in the Explorer window to turn off the visibility of the roads that have a speed higher than 50 km/h. Also, note that I have renamed the thematic layer to show the condition in a more natural language version.


    You can easily change your condition once created via the Theme tab that appears when you select a thematic layer from the Layer List. Click on Expression... at the end of the list and the Expression dialog will appear where you can modify your condition.


    I hope you found this tip useful. If you have any questions, or ideas for next week's #MapInfoMonday tip and trick, use the Comments section below.

    #MapInfoMonday is your weekly little tip​ to help you get more from your MapInfo Pro.

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