# Distance Tool

The Distance tool calculates the ellipsoidal direct point-to-point, point-to-edge, or the drive distance between two sets of spatial objects.

There are three types of distance calculation relationships available.

1. Point-to-point: The Distance tool calculates the distance between two sets of point type spatial objects. An example is calculating the distance from records in a customer file (point type) to records in a store file (point type).
2. Point-to-edge (line): The Distance tool calculates the distance between a set of point type spatial objects and the closest edge of a set of line type spatial objects. An example is calculating the distance from the records in a customer file (point type) to the nearest interstate highway (edge of line spatial type).
3. Point-to-edge (polygon ): The Distance tool calculates the distance between a set of point type spatial objects and the closest edge of a set of polygon type spatial objects.
• When the points are contained within the polygons, you can choose one of two options: Return a distance of zero, or Return the distance to the nearest edge. If the point is located inside of a polygon the Distance tool will return a negative number for the distance to the edge of the containing polygon.
• When the points are contained outside of the polygons, you can also choose to have the Distance tool calculate the Nearest Interior point within the nearest edge of a polygon.
• While this method of calculating distance takes the curvature of the Earth into consideration, it is not a routing routine and does not follow street patterns or honor physical barriers such as bodies of water.

## Configuration Properties

1. Choose the Spatial Object Fields to calculate the distance between. The Source MUST be a point or the centroid of a polygon.
2. The Destination field can be any type of spatial object: point, line, polyline or polygon.

TIP:To optimize the process for speed, the spatial object selected in the Destination(right side) should be the larger spatial object (physically larger), while the object selected in theSource(left side) should be the smaller file (less records).

3. Output Distance Checkbox. When checked, the calculated distance will be outputted in an appended data field.
1. Create the Nearest Interior Point Inside of the Polygon. Checking this box will add a spatial point object to the data stream. It is the distance between the specified Source and this newly created Point that is returned.
2. Select the appropriate radio button to specify the preferred behavior of what to do if a point is within a polygon. Choices include: Return a value of 0 or Return the distance of the nearest edge.
4. Output Drivetime & Distance to Destination Centroid checkbox. When checked, the drivetime in minutes from source to destination will be calculated.
1. Choose the dataset to use in calculating the drivetime and drive distance. If you only have one dataset installed, you will not have the option to select another dataset.
2. You can specify the default dataset from User Settings. Go to Options > User Settings > Edit User Settings and click the Dataset Defaults tab.

3. Select the method for your route to be optimized. Choices include:
• Time: This is the default route. This method finds the route based on the least amount of time between points. When this method is selected, both drivetime and drive distance are returned.
• Distance:This method ignores road speeds to find the most direct route between points. When this method is selected, drive distance is returned. Drivetime is not returned because road speeds were all set to be the same to calculate the most direct route.
4. Allow Reversed Routing for Optimum Speed: When checked, the engine will try to determine if you have significantly more "Source" points than "Destination" points, and if so, it will reverse the two. This will result in somewhat different drivetimes (because of one-way streets), but can yield enormous performance improvements.
5. Drivetime is only available if you have the Drivetime engine installed.

5. Notice the Output Cardinal Direction checkbox. When checked, the direction (N, NE, SW, etc.) will be outputted in an appended data field.
6. Notice the Output Direction in Degrees checkbox. When checked, the distance direction in degrees will be outputted in an appended data field.
7. In the Units section, click either Miles, Kilometers, Meters, or Feet to specify the unit of measure.

The two sets of spatial objects that you specify in the Source and the Destination boxes must be contained within the same data stream or input. You can do this using Alteryxâs other tools "upstream" from the Distance tool in the engine.