DISTANCE(A, B, C, D)
  • 1 Minute to read
  • Dark
    Light
  • PDF

DISTANCE(A, B, C, D)

  • Dark
    Light
  • PDF

Article summary

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

PropertyValue
FieldTypeInteger
FieldSizeShort / Integer
DataTypeDiscrete
DataSizeInteger
Example Return Value: 0 to N, where N is the number of meters between points (A,B) and points (C,D)

Distance_Sample


Parameters

ParameterJSONDescription
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:  
  • DataType: Discrete/Continuous
  • Field Type: Double
  • Fixed Value: #nn.nnnnnnn
B“p3”: "lon_start"Required. The field on the targetTable containing longitude for first pair of coordinates.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value: #nn.nnnnnnn 
C“p4”: "lat_end"
Required.  The field on the targetTable containing latitude for second pair of coordinates.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value: #nn.nnnnnnn 
D“p5”:"lon_end"
Required. The field on the targetTable containing longitude for second pair of coordinates.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value: #nn.nnnnnnn 

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:   

Example

ExampleDetails
DescriptionCalculate straight-line distance between journey start point and end point
Input
  • Table: = [BikeTripData]
  • Function:= Geo
  • Filter: = [No Filter]
  • Geo Function: = DISTANCE(A, B, C, D)
  • A:= lat_Start
  • B:= lon_Start
  • C:= lat_End
  • D:= lon_End
  • Name: =Distance
SampleDistance_Example





Was this article helpful?

What's Next