# Interpolating irregular data on a sphere

I am trying to interpolate irregular data $f(\theta, \phi)$ on a sphere and I have so far tried a scipy approach using Kd-Trees and inverse distance weighting, which works ok - however I was wondering if there is an open-source library for spherical interpolation. I have come across the SHTns library, which is suggested to be useful, but it's not immediately clear to me how to use it for interpolation purposes.

I was wondering if someone could please shed some light on this. Many thanks.

After some more searching I've managed to find what I was looking for. They are available on NETLIB as stripack and ssrfpack - fortran routines - that allow for spherical interpolation of irregular data using spherical splines.

There's also an alternative that uses generalized Green's function for spherical surface splines in tension. The matlab code (and the associated paper) is available there, although it has GMT as a dependency.

On a basic search on Spherical Interpolation I found these:

• Graphics Math Template Library (GMTL)

How do I perform spherical interpolation with quaternions?

Use the slerp function. You need an origin quaternion, a target quaternion, and an interpolation amount between 0 and 1. The following example interpolated halfway between the origin and target quaternions. Note that the interpolation path follows the shortest length arc around a sphere.

  gmtl::Quatf resultQuat, originQuat, targetQuat;
float amount = 0.5;

gmtl::slerp( resultQuat, amount, originQuat, targetQuat );

• Example Code for Spherical Interpolation
• OpenGLDemoEngine: