Skip to main content
This gem runs in .

Overview

Use the Distance gem to calculate the distance between two geographic points.
The gem has a corresponding interactive gem example. See Interactive gem examples to learn how to run sample pipelines for this and other gems.

Prerequisites

  • Add ProphecyDatabricksSqlSpatial version 0.0.1 or higher to your project.

Parameters

Configure the Distance gem using the following parameters.
Geographic points must be in Well-known Text (WKT) format. Use the CreatePoint gem to convert longitude and latitude coordinates to WKT format.

Spatial Object Fields

Use these parameters to specify the columns containing the source and destination geographic points for distance calculation.

Select Output Options

Use the checkboxes defined below to choose which output columns the Distance gem should generate.
You can select zero, one, or multiple checkboxes. All checkboxes are disabled by default.

Example

Assume you have the following airline route table, and you would like to calculate the distance between start and destination cities. To find the distance and direction between cities, set the following gem configurations.
  1. Set source and destination:
    1. Set Source Type to Point.
    2. Set Source Column to start.
    3. Set Destination Type to Point.
    4. Set Destination Column to destination.
  2. Set output options:
    1. Select the Output Distance checkbox.
    2. From the Units dropdown, select Kilometers.
    3. Select the Output Cardinal Direction checkbox.
    4. Select the Output Direction in Degrees checkbox.
    5. Run the gem.

Result

The resulting table will have three new columns: distance_kilometers, cardinal_direction, and direction_degrees.
Scroll horizontally to view the full table.