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
| Property | Value |
|---|---|
| FieldType | Integer |
| FieldSize | Continuous |
| DataType | Continuous |
| DataSize | Integer |
Example Return Value: 1 to N, where N is the number of rows in the lookup tableParameters
| 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": "NEAREST(LT,LN,TLT,TLN)" | NEAREST(LT,LN,TLT,TLN) |
| LT | “p2”: "lat" | Required. The field on the targetTable containing the latitude value. Supports:
|
| LN | “p3”: "lon" | Required. The field on the targetTable containing the longitude value Supports:
|
| TLT | “p4”: "worldcities.lat" | Required. The fully qualified column on the lookup table that contains latitude. Supports:
|
| TLN | “p5”:"worldcities.lng" | Required. The fully qualified column on the lookup table that contains longitude. Supports:
|
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:
Example Lookup Table:
See Also:
Example
| Example | Details |
|---|---|
| Description | Obtain lookup of world city that is nearest to BikePoint |
| Input |
|
| Sample |