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

NEAREST(LT, LN, TLT, TLN)

  • Dark
    Light
  • PDF

Article summary

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

Returns the row number of the nearest point in a lookup table of latitudes and longitudes

Purpose

Use this function to:
  • Identify the nearest lookup location to a set of coordinates
  • Find nearest geographical place
  • Create a continuous integer key that can be used to link to a lookup table

Return Value

PropertyValue
FieldTypeInteger
FieldSizeContinuous
DataTypeContinuous
DataSizeInteger
Example Return Value: 1 to N, where N is the number of rows in the lookup table

Nearest_data


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": "NEAREST(LT,LN,TLT,TLN)"
NEAREST(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”: "worldcities.lat"
Required.  The fully qualified column on the lookup table that contains latitude.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value: #nn.nnnnnnn 
TLN“p5”:"worldcities.lng"
Required. The fully qualified column on the lookup table that contains longitude.
Supports:  
  • DataType: Discrete/Continuous 
  • Field Type: Double 
  • Fixed Value: #nn.nnnnnnn 

JSON Sample

{
  "method": "BuildBakedField",
  "project": "Model1",
  "targetTable": "BikePoints",
  "overwrite": true,
  "name": "Nearest",
  "function": "geo",
  "p1": "NEAREST(LT,LN,TLT,TLN)",
  "p2": "lat",
  "p3": "lon",
  "p4": "worldcities.lat",
  "p5": "worldcities.lng"
}


Usage Notes

NEAREST returns an continuous integer key into the lookup table.   Use this key to create a key to the lookup table, and then copy up specific data-points as required.

Example targetTable:

targetTable

Example Lookup Table:

LookupTable

See Also:   

  • Distance(A, B, C, D)
  • DIST2NEAREST(LT, LN, TLT, TLN)
  • GMNearest, GMDIST2NEAREST 
  • Copy Up
  • Joins

Example

ExampleDetails
DescriptionObtain lookup of world city that is nearest to BikePoint
Input
  • Table: = [BikePoint]
  • Function:= Geo
  • Filter: = [No Filter]
  • Geo Function: = NEAREST(LT, LN, TLT, TLN)
  • LT:= lat
  • LN:= lon
  • TLT:= worldcities.lat
  • TLN:= worldcities.lon
  • Name: =Nearest
SampleNEAREST_Example





Was this article helpful?