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, kindex, 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, kindex, 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... | |
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
[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 (in km) |
[out] | index | zero based index |
[out] | value | value of the field in the nearest point |
[out] | status | CODES_SUCCESS if OK, integer value on error |
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) | kindex, | ||
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.
gribid | id of the GRIB loaded in memory |
is_lsm | .true. if the nearest land point is required otherwise .false. |
inlat | latitude of the point |
inlon | longitudes of the point |
outlat | latitude of the nearest point |
outlon | longitude of the nearest point |
distance | distance between the given point and its nearest |
kindex | zero based index |
value | value of the field in the nearest point |
status | CODES_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.
gribid | id of the grib loaded in memory |
is_lsm | .true. if the nearest land point is required otherwise .false. |
inlats | input real(8) array of the latitudes of the points |
inlons | input real(8) array of the longitudes of the points |
outlats | output real(8) array of the latitudes of the nearest points |
outlons | output real(8) array of the longitudes of the nearest points |
distances | output real(8) array of the distances |
indexes | output integer(4) array of the zero based indexes |
values | output real(8) array of the values |
status | CODES_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) | kindex, | ||
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.
gribid | id of the grib loaded in memory |
is_lsm | .true. if the nearest land point is required otherwise .false. |
inlat | latitude of the point |
inlon | longitudes of the point |
outlat | latitude of the nearest point |
outlon | longitude of the nearest point |
distance | distance between the given point and its nearest |
kindex | zero based index |
value | value of the field in the nearest point |
status | CODES_SUCCESS if OK, integer value on error |