The value in the nearest point (or the four nearest points) is returned as well as the zero based index (which can be used in grib_get_element) and its distance from the given point using the following formula (acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))).
If the is_lsm flag is .true. the input field gribid is considered as a land sea mask and the nearest land point is returned.
The nearest land point among the four neighbours is:
Arrays (real(8)) of latitude/longitude can be provided to find with one call the values,indexes and distances for all the lat/lon points listed in the arrays.
If a single latitude/longitude point is provided and outlat,outlon,value,distance,index are defined as arrays with four elements the lat/lon coordinates and values, distances and indexes of the four nearest points are returned.
In case of error, if the status parameter (optional) is not given, the program will exit with an error message.
Otherwise the error message can be gathered with grib_get_error_string.
Examples: nearest.f90
[in] | gribid | id of the grib loaded in memory |
[in] | is_lsm | .true. if the nearest land point is required otherwise .false. |
[in] | inlat | latitude of the point in degrees |
[in] | inlon | longitudes of the point in degrees |
[out] | outlat | latitude of the nearest point in degrees |
[out] | outlon | longitude of the nearest point in degrees |
[out] | distance | distance between the given point and its nearest |
[out] | index | zero based index |
[out] | value | value of the field in the nearest point |
[out] | status | GRIB_SUCCESS if OK, integer value on error |