hgrib- Unofficial bindings for GRIB API

Copyright(c) Mattias Jakobsson 2015
Safe HaskellSafe




Find the nearest grid points of an arbitrary point.

Most of the documentation herein was copied from the official documentation of grib_api.


The GRIB Nearest Iterator

newtype GribNearest Source

Grib nearest, structure used to find the nearest points of a latitude longitude point.


GribNearest (Ptr GribNearest) 

gribNearestNew :: GribHandle -> IO GribNearest Source

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

The returned object needs to be manually deleted with gribNearestDelete. This is handled automatically by withGribNearest.

gribNearestFind :: GribNearest -> GribHandle -> Double -> Double -> [GribNearestFlag] -> IO ([Double], [Double], [Double], [Double], [Int]) Source

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

gribNearestFindMultiple Source


:: GribHandle

handle from which geography and data values are taken

-> Bool

lsm flag (True -> nearest land, False -> nearest)

-> [Double]

latitudes of the points to search for

-> [Double]

longitudes of the points to search for

-> IO ([Double], [Double], [Double], [Double], [Int])

an IO action that will return a tuple (latitudes, longitudes, values, distances, indices)

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.

gribNearestDelete :: GribNearest -> IO () Source

Frees an nearest from memory.

withGribNearest :: GribHandle -> (GribNearest -> IO a) -> IO a Source

Safely create, use and delete a GribNearest.

This function is an easy alternative over using gribNearestNew and gribNearestDelete directly.

Nearest flags