Last modified: May 17, 2023
One Tool Example
Distance has a One Tool Example. Visit Sample Workflows to learn how to access this and many other examples directly in Alteryx Designer.
Use Distance to calculate 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.
- 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).
- 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).
- 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 returns 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.
Configure the Tool
- Choose the Spatial Object Fields to calculate the distance between them.
- Point or Centroid Source: The source must be a point or the centroid of a polygon to measure from.
- Point, Line, or Polygon Destination: The destination can be any type of spatial object: point, line, polyline, or polygon, and the distance is calculated to reach the closest part of the object.
To optimize the processing speed, connect to the larger spatial object in Destination.
- Output Distance When checked, the calculated distance is output in an appended data field.
- Create the Nearest Interior Point Inside of the Polygon. Check this box to 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.
- Select the preferred behavior of what to do When a point is inside a polygon.
- Return a distance of 0
- Return the distance of the nearest edge
- Output Drivetime & Distance to Destination Centroid checkbox. When checked, the drivetime in minutes from source to destination is calculated.
- 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. You can specify the default dataset from User Settings. Go to Options > User Settings > Edit User Settings and click the Dataset Defaults tab.
- Select the method for your route to be optimized.
- 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, the drive distance is returned. Drivetime is not returned because road speeds were all set to be the same to calculate the most direct route.
Values outside of the maximum do not return an error, but they do not calculate either.
- Allow Reversed Routing for Optimum Speed: When checked, the engine tries to determine if you have significantly more "Source" points than "Destination" points, and if so, it reverses the two. This results in somewhat different drivetimes (because of one-way streets), but can yield enormous performance improvements. Drivetime is only available if you have the Drivetime engine installed.
- Output Cardinal Direction: When checked, the direction (N, NE, SW, etc.) is output in an appended data field.
- Output Direction in Degrees: When checked, the distance direction in degrees is output in an appended data field.
- In the Units section, select Miles, Kilometers, Meters, or Feet to specify the unit of measure.