MapInfo Corporation PreviousNext


Distance Calculator Tool

Adding a Tool to the Tool Manager

Tool Description

The Distance Calculator tool (DistanceCalc.MBX) can be used to calculate the distance from a selected object (or group of objects) to the closest or farthest object(s). You can also specify criteria to limit the results.

Using the Distance Calculator Tool

To use the Distance Calculator tool:

  1. Open the table you want to calculate the distance in.
  2. Select Tools > Distance Calculator to activate the tool.
  3. Note: The Distance Analysis tool works with mappable vector tables only. Distances can not be calculated for raster images.

  4. From the drop-down lists at the upper right part of the Distance Analysis dialog box, you then specify the origin and destination tables and their unique identifying columns.
  5. For example, you can calculate the distance between each customer site listed in the US_CUSTG table and the nearest big city listed in the CITY_125 table. The accompanying Layer Control, Select, Zoom, Pan, and Snap buttons function just as they do throughout the MapInfo Pro interface.

    Note: Some of the files used in this example are taken from the MapInfo Professional Tutorial data, which is available on the MapInfo web site:

  6. When you click Calculate Distance, the results of the distance query are displayed in the browser window. The results may then be cleared (Clear Results) saved to a table (Save Results), or appended to. To discard the current results and generate new results, select Clear Results before recalculating distances.
  7. To append more results, change table, column, and other criteria as desired, then click Calculate Distance. The new results will be added to the bottom of the results table.

  8. Optionally, you can also set destination criteria to limit the results. For example, after checking the Use the following criteria check box you could restrict your results according to selected criteria (for example, to cities with populations greater than a specified number).
  9. Optionally, you can restrict the number of destination distances to find for each origin point. The default is 1.
  10. You can also select the display distance units that are used for calculating distances. The default is miles.
  11. When you click Calculate Distance, the possible destination points are limited to the subset defined by your criteria.

Example of Find Nearest Use

The following example shows the closest distances between California customer sites in the US_CUSTG table and cities with over 2 million population.

  1. Select Layer Control and make sure that the US_CUSTG table is the topmost selectable layer. This may mean that you need to clear the Selectable indicator for other layers.
  2. Use the Boundary Select button to select California. This restricts results to origins (in this example, Customers) within the state of California.
  3. Select "Selection from US_CUSTG" from the origin table drop-down list.
  4. Select "Company" for the origin table identifying column.
  5. Select "CITY-125" for the destination table.
  6. Select "City" for the destination table identifying column.
  7. After checking Use the following criteria, specify Tot_pop > 2000000 to target destination cities with a population greater than 2 million.
  8. In Enter the number of distances to find enter the number 2 to limit the results to two destinations for each origin.
  9. Make sure you Clear Results to clear previous results from the Results Browser window; otherwise the new results would be appended to the previously displayed results.
  10. Click Calculate Distance.

Notes on Using the Distance Calc Tool to Find Nearest/Farthest

The Distance Calculator tool calculates the distance between all the objects in a table or all the objects between two tables and displays the results in a browser window. When you are processing distances for Region or Polyline tables, the processing time may be slower, due to the complex nature of the calculation.

© 2007 MapInfo Corporation. All rights reserved.