Forums

natgrid from matplotlib toolkit

Hi, I'm trying to use to 'natural neighbor' interpolation with matplotlib's griddata. It requires to install natgrid from the toolkits. In the downloaded folder I run:

  python setup.py install --user

resulting in: .local/lib/python2.7/site-packages/mpl_toolkits/natgrid

However, it seems the notebook doesn't find natgrid.

/usr/local/lib/python2.7/dist-packages/matplotlib/mlab.pyc in griddata(x, y, z, xi, yi, interp)
   3465             from mpl_toolkits.natgrid import _natgrid
   3466         except ImportError:
-> 3467             raise RuntimeError("To use interp='nn' (Natural Neighbor "
   3468                 "interpolation) in griddata, natgrid must be installed.  "
   3469                 "Either install it from http://sourceforge.net/projects/">

I believe something needs to restart, but what?

It looks like it needs a C library to be installed. You could try downloading and compiling it manually and installing it locally, but I'm not at all sure how that would work.

Otherwise, we'll make a note to see if we can get it installed for next time we do a server image rebuild...

The setup.py compiled a lib called "_natgrid.so", but while

from mpl_toolkits.basemap import Basemap

works

from mpl_toolkits.natgrid import _natgrid

fails.

Like I say, compiling C libraries is above my pay grade... maybe you'll find some help in the natgrid docs?