I am interpolating data from satellite imagery. My initial data is not on a regular grid. The data e.g. ch1
refers to positions given by longitude
and latitude
. When I try nearest neighbour interpolation the result I get is good.
from scipy import interpolate
lats = np.arange(latitude.max(), latitude.min(),-.1)
lons = np.arange(longitude.min(),longitude.max(),.1)
all_lon,all_lat = np.meshgrid(lons,lats)
ch1_all = interpolate.griddata((longitude.reshape(-1),latitude.reshape(-1)),ch1.reshape(-1),(all_lon,all_lat),'nearest')
However when I request bilinear interpolation I raise a Qhull error.
ch1_all = interpolate.griddata((longitude.reshape(-1),latitude.reshape(-1)),ch1.reshape(-1),(all_lon,all_lat),'linear')
The error I get is:
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\scipy\interpolate\ndgriddata.py", line 206, in griddata
rescale=rescale)
File "interpnd.pyx", line 239, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__ (scipy\interpolate\interpnd.c:4549)
File "qhull.pyx", line 1736, in scipy.spatial.qhull.Delaunay.__init__ (scipy\spatial\qhull.c:13719)
File "qhull.pyx", line 328, in scipy.spatial.qhull._Qhull.__init__ (scipy\spatial\qhull.c:3602)
QhullError: Qhull error
I have read the post at griddata runtime error -- Python / SciPy (Interpolation) but in my case, it interpolates data with one method but not with the other.
What am I doing wrong?
In the image below I have plotted the final point positions (red) and overlaid the initial positions (blue)