Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Interpolation of geo-referenced data for Python.

Project description

Build Status conda platforms latest-release-date license Binder


Python library for optimized geo-referenced interpolation.


The motivation of this project is to provide tools for interpolating geo-referenced data used in the field of geosciences. There are other libraries that cover this problem, but written entirely in Python, the performance of these projects was not quite sufficient for our needs. That is why this project was created.

This version can interpolate 2D fields using bivariate and bicubic interpolators, 3D fields using trivariate interpolators and unstructured grid. You can also apply a data binning on bivariate field by simple or linear binning.

The library core is written in C++ using the Boost C++ Libararies, Eigen3, GNU Scientific Library and pybind11 libraries.

This software also uses CMake to configure the project and Googletest to perform unit testing of the library kernel.

Fill undefined values

The undefined values in the grids do not allow interpolation of values located in the neighborhood. This behavior is a concern when you need to interpolate values near the mask of some fields. The library provides utilities to fill the undefined values:

  • loess to fill the undefined values on the boundary between the defined/undefined values using local regression.
  • gauss_seidel to fill all undefined values in a grid using the Gauss-Seidel method by relaxation.

Geographic indexers

N-Dimensional Grids

N-dimensional grid is a grid defined by a matrix, in a 2D space, by a cube in a 3D space, etc. Each dimension of the grid is associated with a vector corresponding to its coordinates or axes. Axes are used to locate a pixel in the grid from the coordinates of a point. These axes are either:

  • regular: latitudes are defined by a vector of 181 values spaced a degree from -90 to 90 degrees;
  • irregular: latitudes are represented by a vector of 109 values irregularly spaced from -90 to 89.940374 degrees.

These objects are manipulated by the class pyinterp.core.Axis which will choose, according to the definition of the axis, the best implementation. This object will allow you to find the two indexes framing a given value. This operating mode allows better performance when searching for a regular axis (a simple calculation allows you to immediately find the index of a point) while in the case of an irregular axis, the search will be performed using a binary search.

Finally, this object is able to define a circular axis from a vector in order to correctly locate a value on the circle. This is the type of axis that will be used when handling longitudes.

Unstructured Grids

In the case of unstructured grids, the index used is a R*Tree. These trees have better performance than the KDTree generally found in Python library implementations.

The tree used here is the implementation provided by the C++ Boost library.

An adaptation has been introduced to effectively address spherical equatorial coordinates. Although the Boost library allows these coordinates to be manipulated natively, but the performance is lower than in the case of a Cartesian space. Thus, we have chosen to implement a conversion of Longitude Latitude Altitude (LLA) coordinates into Earth-Centered, Earth-Fixed (ECEF) coordinates in a transparent way for the user to ensure that we are able to preserve good performance. The disadvantage of this implementation is that it requires a little more memory, as one more element must be used to index the value of the Cartesian space.

The management of the LLA/ECEF coordinate conversion is managed to use the Olson, D.K. algorithm. It has excellent performance with an accuracy of 1e-8 meters for altitude.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyinterp, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size pyinterp-0.0.7.tar.gz (5.0 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page