eccodes: Iterating on latitude/longitude/values

eccodes

- Main Page
- C Interface
- F90 Interface
- Python Interface

All Data Structures Namespaces Files Functions Groups Pages
Data Structures | Functions
Iterating on latitude/longitude/values

## Data Structures
struct | codes_iterator
struct | codes_nearest

## Functions
codes_iterator * | codes_grib_iterator_new (codes_handle *h, unsigned long flags, int *error)
| Create a new iterator from a GRIB handle, using current geometry and values. More...
int | codes_grib_get_data (codes_handle *h, double *lats, double *lons, double *values)
| Get latitude/longitude and data values. More...
int | codes_grib_iterator_next (codes_iterator *i, double *lat, double *lon, double *value)
| Get the next value from an iterator. More...
int | codes_grib_iterator_previous (codes_iterator *i, double *lat, double *lon, double *value)
| Get the previous value from an iterator. More...
int | codes_grib_iterator_has_next (codes_iterator *i)
| Test procedure for values in an iterator. More...
int | codes_grib_iterator_reset (codes_iterator *i)
| Test procedure for values in an iterator. More...
int | codes_grib_iterator_delete (codes_iterator *i)
| Frees an iterator from memory. More...
codes_nearest * | codes_grib_nearest_new (codes_handle *h, int *error)
| Create a new nearest from a handle, using current geometry . More...
int | codes_grib_nearest_find (codes_nearest *nearest, codes_handle *h, double inlat, double inlon, unsigned long flags, double *outlats, double *outlons, double *values, double *distances, int *indexes, size_t *len)
| Find the 4 nearest points of a latitude longitude point. More...
int | codes_grib_nearest_delete (codes_nearest *nearest)
| Frees an nearest from memory. More...
int | codes_grib_nearest_find_multiple (codes_handle *h, int is_lsm, double *inlats, double *inlons, long npoints, double *outlats, double *outlons, double *values, double *distances, int *indexes)
| Find the nearest point of a set of points whose latitudes and longitudes are given in the inlats, inlons arrays respectively. More...

## Detailed Description

## Function Documentation

int codes_grib_get_data | ( | codes_handle * | h,
|  | double * | lats,
|  | double * | lons,
|  | double * | values
| ) |  |

Get latitude/longitude and data values.

The Latitudes, longitudes and values arrays must be properly allocated by the caller. Their required dimension can be obtained by getting the value of the integer key "numberOfPoints".

Parameters

  h | : handle from which geography and data values are taken
  lats | : returned array of latitudes
  lons | : returned array of longitudes
  values | : returned array of data values

Returns
  0 if OK, integer value on error

int codes_grib_iterator_delete | ( | codes_iterator * | i | ) |

Frees an iterator from memory.

Parameters

  i | : the iterator

Returns
  0 if OK, integer value on error

int codes_grib_iterator_has_next | ( | codes_iterator * | i | ) |

Test procedure for values in an iterator.

Parameters

  i | : the iterator

Returns
  boolean, 1 if the iterator still nave next values, 0 otherwise

codes_iterator* codes_grib_iterator_new | ( | codes_handle * | h,
|  | unsigned long | flags,
|  | int * | error
| ) |  |

Create a new iterator from a GRIB handle, using current geometry and values.

Parameters

  h | : the handle from which the iterator will be created
  flags | : flags for future use.
  error | : error code

Returns
  the new iterator, NULL if no iterator can be created

int codes_grib_iterator_next | ( | codes_iterator * | i,
|  | double * | lat,
|  | double * | lon,
|  | double * | value
| ) |  |

Get the next value from an iterator.

Parameters

  i | : the iterator
  lat | : on output latitude in degree
  lon | : on output longitude in degree
  value | : on output value of the point

Returns
  positive value if successful, 0 if no more data are available

int codes_grib_iterator_previous | ( | codes_iterator * | i,
|  | double * | lat,
|  | double * | lon,
|  | double * | value
| ) |  |

Get the previous value from an iterator.

Parameters

  i | : the iterator
  lat | : on output latitude in degree
  lon | : on output longitude in degree
  value | : on output value of the point*

Returns
  positive value if successful, 0 if no more data are available

int codes_grib_iterator_reset | ( | codes_iterator * | i | ) |

Test procedure for values in an iterator.

Parameters

  i | : the iterator

Returns
  0 if OK, integer value on error

int codes_grib_nearest_delete | ( | codes_nearest * | nearest | ) |

Frees an nearest from memory.

Parameters

  nearest | : the nearest

Returns
  0 if OK, integer value on error

int codes_grib_nearest_find | ( | codes_nearest * | nearest,
|  | codes_handle * | h,
|  | double | inlat,
|  | double | inlon,
|  | unsigned long | flags,
|  | double * | outlats,
|  | double * | outlons,
|  | double * | values,
|  | double * | distances,
|  | int * | indexes,
|  | size_t * | len
| ) |  |

Find the 4 nearest points of a latitude longitude point.

The flags are provided to speed up the process of searching. If you are sure that the point you are asking for is not changing from a call to another you can use CODES_NEAREST_SAME_POINT. The same is valid for the grid. Flags can be used together doing a bitwise OR. The distances are given in kilometres.

Parameters

  nearest | : nearest structure
  h | : handle from which geography and data values are taken
  inlat | : latitude of the point to search for
  inlon | : longitude of the point to search for
  flags | : CODES_NEAREST_SAME_POINT, CODES_NEAREST_SAME_GRID
  outlats | : returned array of latitudes of the nearest points
  outlons | : returned array of longitudes of the nearest points
  values | : returned array of data values of the nearest points
  distances | : returned array of distances from the nearest points
  indexes | : returned array of indexes of the nearest points
  len | : size of the arrays

Returns
  0 if OK, integer value on error

int codes_grib_nearest_find_multiple | ( | codes_handle * | h,
|  | int | is_lsm,
|  | double * | inlats,
|  | double * | inlons,
|  | long | npoints,
|  | double * | outlats,
|  | double * | outlons,
|  | double * | values,
|  | double * | distances,
|  | int * | indexes
| ) |  |

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

If the flag is_lsm is 1 the nearest land point is returned and the grib passed as handle (h) is considered a land sea mask. The land nearest point is the nearest point with land sea mask value>=0.5. If no nearest land points are found the nearest value is returned. If the flag is_lsm is 0 the nearest point is returned. values, distances, indexes (in the "values" array) for the nearest points (ilons,ilats) are returned. The distances are given in kilometres.

Parameters

  h | : handle from which geography and data values are taken
  is_lsm | : lsm flag (1-> nearest land, 0-> nearest)
  inlats | : latitudes of the points to search for
  inlons | : longitudes of the points to search for
  npoints | : number of points (size of the inlats,inlons,outlats,outlons,values,distances,indexes arrays)
  outlats | : returned array of latitudes of the nearest points
  outlons | : returned array of longitudes of the nearest points
  values | : returned array of data values of the nearest points
  distances | : returned array of distances from the nearest points
  indexes | : returned array of indexes of the nearest points

Returns
  0 if OK, integer value on error

codes_nearest* codes_grib_nearest_new | ( | codes_handle * | h,
|  | int * | error
| ) |  |

Create a new nearest from a handle, using current geometry .

Parameters

  h | : the handle from which the iterator will be created
  error | : error code

Returns
  the new nearest, NULL if no nearest can be created