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.
For information about how to add a tool to the Tool Manager, see Working with MapInfo Pro Tools.
Using the Distance Calculator Tool
To use the Distance Calculator tool:
- Open the table you want to calculate the distance in.
- Run the Distance Calculator tool to open the Distance Analysis window. See Running a Tool for details.
On the MAP tab, in the Options group, click Map Tools, and then click Distance Calculator.
- From the drop-down lists at the upper right part of the Distance Analysis dialog box, you specify the origin and destination tables and their unique identifying columns.
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.
- 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.
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.
- 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).
- Optionally, you can restrict the number of destination distances to find for each origin point. The default is 1.
- You can also select the display distance units that are used for calculating distances. The default is miles.
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.
- 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.
- Use the Boundary Selection command to select California (on the MAP tab, in the Selection group, click Boundary Selection from the selection list). This restricts results to origins (in this example, Customers) within the state of California.
- Select Selection from US_CUSTG from the origin table drop-down list.
- Select Company for the origin table identifying column.
- Select CITY-125 for the destination table.
- Select City for the destination table identifying column.
- After checking Use the following criteria, specify Tot_pop > 2000000 to target destination cities with a population greater than 2 million.
- In Enter the number of distances to find enter the number 2 to limit the results to two destinations for each origin.
- 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.
- 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.