Skip to content
Thomas Nipen edited this page Apr 21, 2020 · 60 revisions

The gridpp library contains functions for the core algorithms in gridpp. As the command-line version of gridpp was built first, we are gradually collecting all the funtionality into a library. The library is written in C++, but automatic wrappers for python are created using SWIG. Bindings for other languages (like R) will be added in the future. All examples using the library in this wiki use the python interface.

The documentation for the library is found here. The header file with the available functions can be found in include/gridpp.h.

The library consists mostly of functions that take scalars (float, int) and vectors (1D, 2D, 3D std::vector) as inputs.

Classes for describing locations

The gridpp library supports two classes for describing geographical positions in datasets. The Grid class encapsulates a 2 dimensional gridded field of locations. The Points class encapsulates a 1 dimensional vector of locations.

The library operates exclusively with latitude,longitude coordinates, instead of x,y coordinates on projected grids. This means grids do not need to be on a specific projection. The latitude/longitude coordinates are converted to 3D spherical coordinates and distances between points are calculated in 3D space. Thus distances do not follow the curvature of the earth byt are straight-line distance through the earth. This has little impact for most applications.

Both classes have efficient methods for retrieving the nearest point, the nearest N points, and all points within a specified radius. Grid and Points use the helper class KDTree, which uses the rtree implementation in boost.

Exceptions

Functions will throw std::invalid_argument exceptions when input arguments are invalid (e.g. dimension mismatch between arguments) and std::runtime_error for other errors.

Clone this wiki locally