# Spatial Functions with the Formula Tool

Alteryx
Created

Alteryx’s spatial functions are not limited to the tools found in the Spatial Palette.  The Formula Tool, for example, has a variety of spatial functions that expand the Designer’s spatial capabilities beyond those in the Spatial Tool Palette.  This article highlights the Formula Tool’s ability to create spatial objects, particularly points and lines, and calculate distance using the built-in expression library (Figure 1).

Figure 1: One of the Formula Tool's expression library contains spatial functions, which can be used to create spatial objects, perform spatial calculations, and retrieve spatial information.

For the most part, the spatial functionalities included in the Formula Tool expression library are available in tool in the Spatial Palette.  However, rather than dragging on multiple spatial tools to complete a process, using the spatial expressions in a single Formula Tool allows you to create a more streamlined workflow.  Consider the example workflow that accompanies this article.  The input data consists of two sets of Lat/Long coordinates, one for the start point and one for the endpoint.  The objectives of the workflow are to 1) create points for the start and end locations, 2) create a line connecting the start and end locations, and 3) calculate the distance between the two points.  Believe it or not, all three of these processes can be accomplished using a single tool!  In the attached v10.0 workflow, Workflow A (top) uses four expressions in a Formula Tool (Figure 2A).  Workflow B (bottom) uses the spatial tools to accomplish the same task.  This approach requires 8 different tools to configure the data, create spatial objects and perform the distance calculations (Figure 2B).  Both workflows achieve the same results but, in the spirit of minimalism, the Formula Tool’s ability to handle spatial processes efficiently and effectively certainly deserves some kudos!

Figure 2A: Completing spatial functions in a Formula Tool.

Figure 2B: Using Spatial tools (and others) to complete the task.  Green text boxes indicate which expression(s) in the Formula Tool accomplishes the same task.