MapInfo Pro

 View Only
  • 1.  MapBasic Tool of the Week: Distance Calculator

    Posted 05-23-2019 03:55

    PROBLEM  -  The Director of Network Operations would like to know the average distance a customer in their membership program is away from their nearest store.  Whilst the Director understand that using routing would deliver a more real-world answer to the question, they have been called in by the General Manager to answer this question at a meeting in 5 minutes time – straight-line distance will be adequate in this instance.
    DistanceCalculator1

    Here, we will be focusing on one of the in-built tools that ship with MapInfo Pro – Distance Calculator.  Put simply, the Distance Calculator tool calculates the distance from a selected object (or group of objects) to the closest or farthest object(s).  Whilst it is possible to apply the Distance Calculator to a single table, the typical scenario (as per the examples mentioned above) occurs between two tables.  The Distance Calculator operates with points, line or polygons and selection criteria can be applied to control the results (for example, find me the nearest 5 sites from each starting point and ignore values equal to 0).

    SOLUTION  -  Fortunately, the membership data (Customers) is already mapped as are the store points (Sites).  Both datasets are opened into a map window in MapInfo Pro as per the sample image above.

    The Distance Calculator tool can be accessed in multiple ways.  A quick and easy way to locate any of the functionality within MapInfo Pro is to use the Quick Search tool in the top right-hand corner of the program window.  By typing "distance calculator" in to the Quick Search panel, there are 2 options immediately presented as ways of accessing the Distance Calculator tool.

    Distance Calculator 2

    I choose to select the second option listed and am then presented with the "Distance Analysis" dialog box.  The left hand side of the Distance Calculator dialog has selection tools that allow objects to be selected spatially (if appropriate) from the map window provided as part of the dialog, and there are controls to switch between Map windows. The origin and destination tables used in the calculation are selected on the right hand side of the dialog.  Customers1 will be the "origin" and Sites1 the "destination" tables used in this example.  The right-hand side also allows for the configuration of criteria impacting on the outcome.  In the "Set Criteria for Destination" area below, there is some attribute related selection criteria to filter the destination locations to be used in the calculation of distances if necessary.

    Distance Calculator 3
    The problem to be solved in this instance only needs the nearest retail location (no filters) to all customers, so in this instance the dialog will be completed to "Find the closest point" and 1 will be entered against "Enter the number of distances to find".  If the answer required the nearest 5 sites then the number entered against the number of distances to find would be 5.

    In this example I have also unchecked the "Ignore distance of 0" option as I do not want to exclude any outcomes.  Note  - this option is particularly useful when using the Distance Calculator on a single table in order to exclude the origin point also being considered as a destination point.  To solve this problem and provide the Director with the information they need, we want the distances calculated to be returned in "kilometres" so we choose that as the distance unit to apply from the relevant dropdown box.

    Once satisfied that the correct origin, destination and criteria information has been entered, click "Calculate" to perform the calculations as defined.  Outcomes generated are placed in the browser part of the dialog in the bottom left-hand corner.

    Distance Calculator 4

    Once the process is complete click on the "Save Results" button to save the outcome.  Once saved, open the table in MapInfo Pro and you will see that the Distance Calculator not only delivers the tabular results as shown in the dialog box but also produces a line linking each location with the nearest site.
    Distance Calculator 5
    At this point there are a number of methods available to generate the average distance travelled by a customer to a store.  A very simple approach is to take advantage of another built-in tool under the Table tab – Calculate Statistics.

    Distance Calculator 6
    Click on "Calculate Statistics" and enter the table name calculated by the Distance Calculator and the field that contains the distances.  Then click OK and a group of summary statistics are returned which include the minimum, maximum and average (Mean) distance.

    Distance Calculator 1
    So, within a matter of just a couple of minutes MapInfo Pro and the Distance Calculator have delivered to the Director the required information for their meeting with the General Manager – making them look good in front of their Boss and highlighting the value of location intelligence to the business.  A classic case of Win/Win powered by the capability of MapInfo Pro.

    We would love to hear how MapInfo Pro users have applied the Distance Calculator in solving various business problems or just let us know what your favourite MapInfo Pro MBX is.



    ------------------------------
    Tony Maber
    Location Analytics & Data - PreSales
    Pitney Bowes
    Sydney - Australia
    ------------------------------


  • 2.  RE: MapBasic Tool of the Week: Distance Calculator

    Posted 05-23-2019 21:42
    Hi @Tony Maber - thanks for sharing a fantastic real world use of the Distance Calculator tool.

    Wanted to share a couple of observations in addition to your write-up:
    1. Using a raster backdrop & setting to greyscale (as per your screenshots) is a really effective ​way of giving geographic context without distracting from the real "stars" of the map (the layers of customers/branches)
    2. Using the results from Distance Calculator it's easy to go one more step & update the customers table with the distance to nearest branch and then use this field for a thematic:

    also the Customers can be shaded by colour to show the association with nearest branch:

    which really helps to communicate the story of the map to the audience.

    ------------------------------
    Ashley Crane
    Regional Director, Software Support
    Pitney Bowes
    ------------------------------



  • 3.  RE: MapBasic Tool of the Week: Distance Calculator

    Posted 05-24-2019 00:02
    Hi Ashley.  Thanks for your great additional comments on using the Distance Calculator tool in MapInfo Pro and taking the results to deliver enhanced spatial displays and analysis.

    ------------------------------
    Tony Maber
    Location Analytics & Data - PreSales
    Pitney Bowes
    Sydney - Australia
    ------------------------------