eccodes
 All Data Structures Namespaces Files Functions Groups Pages
Public Member Functions
eccodes::codes_grib_find_nearest Interface Reference

Find the nearest point/points of a given latitude/longitude point. More...

Public Member Functions

subroutine codes_grib_find_nearest_single (gribid, is_lsm, inlat, inlon, outlat, outlon, value, distance, index, status)
 Find the nearest point of a given latitude/longitude point. More...
 
subroutine codes_grib_find_nearest_four_single (gribid, is_lsm, inlat, inlon, outlat, outlon, value, distance, index, status)
 Find the 4 nearest points of a latitude longitude point. More...
 
subroutine codes_grib_find_nearest_multiple (gribid, is_lsm, inlats, inlons, outlats, outlons, values, distances, indexes, status)
 Find the nearest point of a set of points whose latitudes and longitudes are given in the inlats, inlons arrays respectively. More...
 

Detailed Description

Find the nearest point/points of a given latitude/longitude point.

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 codes_get_element) and its distance from the given point using the following formula radius * 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 codes_get_error_string.

Examples: grib_nearest.f90

Parameters
[in]gribidid of the grib loaded in memory
[in]is_lsm.true. if the nearest land point is required otherwise .false.
[in]inlatlatitude of the point in degrees
[in]inlonlongitudes of the point in degrees
[out]outlatlatitude of the nearest point in degrees
[out]outlonlongitude of the nearest point in degrees
[out]distancedistance between the given point and its nearest (in km)
[out]indexzero based index
[out]valuevalue of the field in the nearest point
[out]statusCODES_SUCCESS if OK, integer value on error

Member Function/Subroutine Documentation

subroutine codes_grib_find_nearest_four_single ( integer(kind=kindofint), intent(in)  gribid,
logical, intent(in)  is_lsm,
real(kind = kindofdouble), intent(in)  inlat,
real(kind = kindofdouble), intent(in)  inlon,
real(kind = kindofdouble), dimension(4), intent(out)  outlat,
real(kind = kindofdouble), dimension(4), intent(out)  outlon,
real(kind = kindofdouble), dimension(4), intent(out)  value,
real(kind = kindofdouble), dimension(4), intent(out)  distance,
integer(kind = kindofint), dimension(4), intent(out)  index,
integer(kind=kindofint), intent(out), optional  status 
)

Find the 4 nearest points of a latitude longitude point.

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 codes_get_error_string.

Parameters
gribidid of the GRIB loaded in memory
is_lsm.true. if the nearest land point is required otherwise .false.
inlatlatitude of the point
inlonlongitudes of the point
outlatlatitude of the nearest point
outlonlongitude of the nearest point
distancedistance between the given point and its nearest
indexzero based index
valuevalue of the field in the nearest point
statusCODES_SUCCESS if OK, integer value on error
subroutine codes_grib_find_nearest_multiple ( integer(kind=kindofint), intent(in)  gribid,
logical, intent(in)  is_lsm,
real(kind = kindofdouble), dimension(:), intent(in)  inlats,
real(kind = kindofdouble), dimension(:), intent(in)  inlons,
real(kind = kindofdouble), dimension(:), intent(out)  outlats,
real(kind = kindofdouble), dimension(:), intent(out)  outlons,
real(kind = kindofdouble), dimension(:), intent(out)  values,
real(kind = kindofdouble), dimension(:), intent(out)  distances,
integer(kind = kindofint), dimension(:), intent(out)  indexes,
integer(kind=kindofint), intent(out), optional  status 
)

Find the nearest point of a set of points whose latitudes and longitudes are given in the inlats, inlons arrays respectively.

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 codes_get_error_string.

Parameters
gribidid of the grib loaded in memory
is_lsm.true. if the nearest land point is required otherwise .false.
inlatsinput real(8) array of the latitudes of the points
inlonsinput real(8) array of the longitudes of the points
outlatsoutput real(8) array of the latitudes of the nearest points
outlonsoutput real(8) array of the longitudes of the nearest points
distancesoutput real(8) array of the distances
indexesoutput integer(4) array of the zero based indexes
valuesoutput real(8) array of the values
statusCODES_SUCCESS if OK, integer value on error
subroutine codes_grib_find_nearest_single ( integer(kind=kindofint), intent(in)  gribid,
logical, intent(in)  is_lsm,
real(kind = kindofdouble), intent(in)  inlat,
real(kind = kindofdouble), intent(in)  inlon,
real(kind = kindofdouble), intent(out)  outlat,
real(kind = kindofdouble), intent(out)  outlon,
real(kind = kindofdouble), intent(out)  value,
real(kind = kindofdouble), intent(out)  distance,
integer(kind = kindofint), intent(out)  index,
integer(kind=kindofint), intent(out), optional  status 
)

Find the nearest point of a given latitude/longitude point.

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 codes_get_error_string.

Parameters
gribidid of the grib loaded in memory
is_lsm.true. if the nearest land point is required otherwise .false.
inlatlatitude of the point
inlonlongitudes of the point
outlatlatitude of the nearest point
outlonlongitude of the nearest point
distancedistance between the given point and its nearest
indexzero based index
valuevalue of the field in the nearest point
statusCODES_SUCCESS if OK, integer value on error

The documentation for this interface was generated from the following file:
This website is beyond its original expiry date and the content may be out of date. The site owner has been notified and may choose to extend the expiry date and remove this banner. If you have any questions about this, please visit our support portal.