DISTANCE(A, B, C, D)
- 1 Minute to read
- Print
- DarkLight
- PDF
DISTANCE(A, B, C, D)
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Geo: DISTANCE(A, B, C, D)
Calculates the distance of earth's surface, in meters, between pairs of coordinates (A,B) and (C,D)
Purpose
Use this function to:
- Calculate the distance in meters between 2 sets of coordinates
- Calculate the distance between points on a map
Return Value
Property | Value |
---|---|
FieldType | Integer |
FieldSize | Short / Integer |
DataType | Discrete |
DataSize | Integer |
Example Return Value: 0 to N, where N is the number of meters between points (A,B) and points (C,D)
Parameters
Parameter | JSON | Description |
---|---|---|
Table | “targetTable”: “MyTableName” | The target table on which the new field will be created |
Filter | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter DataSet will be returned as null. |
Function | "function":"geo" | Geo |
Geo Function | "p1": "DISTANCE(A, B, C, D)" | DISTANCE(A, B, C, D) |
A | “p2”: "lat_start" | Required. The field on the targetTable containing latitude for first pair of coordinates. Supports:
|
B | “p3”: "lon_start" | Required. The field on the targetTable containing longitude for first pair of coordinates. Supports:
|
C | “p4”: "lat_end" | Required. The field on the targetTable containing latitude for second pair of coordinates. Supports:
|
D | “p5”:"lon_end" | Required. The field on the targetTable containing longitude for second pair of coordinates. Supports:
|
JSON Sample
{
"method": "BuildBakedField",
"project": "Model1",
"targetTable": "BikeTripData",
"overwrite": true,
"name": "Distance",
"function": "geo",
"p1": "DISTANCE(A,B,C,D)",
"p2": "lat_Start",
"p3": "lon_Start",
"p4": "lat_End",
"p5": "lon_End"
}
Usage Notes
DISTANCE returns an integer value, representing the number of meters between the first and second set of coordinates. The method used is
distance = Sqrt ( (C - A)2 + (D - B)2 )
See Also:
- Nearest(LT, LN, TLT, TLN)
- DIST2NEAREST(LT, LN, TLT, TLN)
- GMNearest, GMDIST2NEAREST
- Copy Up
- Joins
Example
Example | Details |
---|---|
Description | Calculate straight-line distance between journey start point and end point |
Input |
|
Sample |
Was this article helpful?