Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
nearest_gridpoint
nearest_gridpoint
number or list nearest_gridpoint ( fieldset,list[,string] )
number or list nearest_gridpoint ( fieldset,number,number[,string] )
vector or list nearest_gridpoint ( fieldset,vector,vector[,string] )

Returns the value of the nearest point to a given location (or locations) in each field of a fieldset. The field must be a gridded field. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. For batch processing of multiple locations, two vectors can be given, the first is a vector of latitudes, the second the longitudes; this can be much more efficient than multiple calls with a single location each. If the fieldset has only one field, a number (or vector) is returned; otherwise a list of numbers (or a list of vectors) is returned.

When By default, when the nearest gridpoint value is a missing value or the location is out of the grid areanil is returned in the case of a single coordinate, or vector_missing_value in the case of a vector. If an extra parameter 'valid' is added to the function call, then of the surrounding points, the nearest valid one is returned; nil will still be returned if all the surrounding points are missing.

Note that a similar function, interpolate(), also exists.

...

Anchor
nearest_gridpoint_info
nearest_gridpoint_info
list nearest_gridpoint_info ( fieldset,list[,string] )
list nearest_gridpoint_info ( fieldset,number,number[,string] )

Returns the value and location of the nearest point to a given location in each field of a fieldset. If a list is given, it must contain two numbers - latitude and longitude. If two numbers are given, the first is the latitude, the second the longitude. The field must be a lat-long field. The return value is a list of definitions, one for each field, and each containing the following members: value , latitude , longitude . Where it is not possible to generate a sensible value due to lack of valid data in the fieldset, nil is returned. If an extra parameter 'valid' is added to the function call, then of the surrounding points, the nearest valid one is returned; nil will still be returned if all the surrounding points are missing.

The following example illustrates how to use the function.

...