DIST2NEAREST(LT, LN, TLT, TLN)
  • 1 Minute to read
  • Dark
    Light
  • PDF

DIST2NEAREST(LT, LN, TLT, TLN)

  • Dark
    Light
  • PDF

Article summary

Geo: DIST2NEAREST (LT, LN, TLT, TLN)

Returns the distance, in meters, from (LT,LN) to the nearest location, as found in lookup fields (TLT, TLN)

Purpose

Use this function to:
  • Calculate the distance between a geographical location and its nearest location in a lookup table
  • Find the distance between a geographical point and another location, where the location search has a minimum range to search above

Return Value

PropertyValue
FieldTypeInteger
FieldSizeContinuous
DataTypeContinuous
DataSizeInteger
Example Return Value: 0 to N, where:
 - N is the number of meters between points (LT, LN) and points (TLT, TLN)
 - N is greater than the value provided by limiter

DistanceToNearest_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": "DIST2NEAREST(LT,LN,TLT,TLN)"DIST2NEAREST(LT,LN,TLT,TLN)
LT“p2”: "lat"Required.  The field on the targetTable containing the latitude value.
Supports:  
  • DataType: Discrete/Continuous
  • Field Type: Double
  • Fixed Value: #nn.nnnnnnn
LN“p3”: "lon"Required. The field on the targetTable containing the longitude value
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value:#nn.nnnnnnn 
TLT“p4”: "lat"Required.  The fully qualified column on the lookup table that contains latitude. Can be on a lookup table or on the targetTable.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value:#nn.nnnnnnn 
TLN“p5”:"lon"Required. The fully qualified column on the lookup table that contains longitude. Can be on a lookup table or on the targetTable. 
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value:#nn.nnnnnnn
Limiter“limiter”:"#1"Optional.   The column or value that provides a minimum threshold - values below the threshold will be excluded.   Note that fixed values represent meters.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value:#nn.nnnnnnn 

JSON Sample

{
  "method": "BuildBakedField",
  "project": "Matching1",
  "targetTable": "worldcities",
  "overwrite": true,
  "name": "Distance To Nearest City",
  "function": "geo",
  "p1": "DIST2NEAREST(LT,LN,TLT,TLN)",
  "p2": "lat",
  "p3": "lng",
  "p4": "worldcities.lat",
  "p5": "worldcities.lng",
  "limiter": "#1"
}

Usage Notes

DIST2NEAREST returns an integer value representing the number of meters between the 2 points.   Nearest points which are below the threshold specified by "limiter" will be excluded.    

For more information on using Geo functions, see QQ - How do I get the name of the nearest city from a table of Geo Data?


See Also:   

Example

ExampleDetails
DescriptionFind distance to nearest city in meters
Input
  • Table: = [worldcities]
  • Function:= Geo
  • Filter: = [No Filter]
  • Geo Function: = "DIST2NEAREST(LT,LN,TLT,TLN)
  • LT:= lat
  • LN:= lon
  • TLT:= worldcities.lat
  • TLN:= worldcities.lon
  • Limiter:=#1
  • Name: =Distance to Nearest City
SampleDistanceToNearest_Example






Was this article helpful?