Calculate Distance
Calculates the straight-line (as the crow flies) distance between two geographic coordinates using the Haversine formula.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Coordinate 1 - First geographic coordinate in "latitude,longitude" format (e.g., "41.0082,28.9784").
- Coordinate 2 - Second geographic coordinate in "latitude,longitude" format (e.g., "40.7128,74.0060").
Output
- Distance - The straight-line distance between the two coordinates in kilometers.
How It Works
The Calculate Distance node computes the straight-line distance between two geographic coordinates using the Haversine formula. When executed, the node:
- Validates both coordinate inputs
- Parses the latitude and longitude values from each coordinate string
- Applies the Haversine formula to calculate the great-circle distance
- Returns the distance in kilometers
The Haversine formula accounts for the Earth's curvature, providing accurate distance calculations between any two points on the globe.
Requirements
- Two valid geographic coordinates in "latitude,longitude" format
- Coordinates must be expressed as decimal degrees
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Coordinate 1 input
- Empty or invalid Coordinate 2 input
- Incorrect coordinate format (missing comma or invalid numbers)
- Non-numeric latitude or longitude values
Usage Notes
- Coordinates should be provided in decimal degrees format
- The distance is calculated as a straight line (not road distance)
- The result is returned in kilometers
- For coordinate formatting, use a comma without spaces (e.g., "41.0082,28.9784")
- This calculation is useful for proximity checks and rough distance estimations
- For driving distances, use the Get Route Distance node instead