title: Inverse Distance Weighted (IDW) Interpolation with Python
body: <p><strong>The Question:</strong>
  What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations?</p>
  
  <p><strong>Some Background:</strong>
  Currently I'm using RPy2 to interface with R and its gstat module.  Unfortunately, the gstat module conflicts with arcgisscripting which I got around by running RPy2 based analysis in a separate process.  Even if this issue is resolved in a recent/future release, and efficiency can be improved, I'd still like to remove my dependency on installing R.</p>
  
  <p>The gstat website does provide a stand alone executable, which is easier to package with my python script, but I still hope for a Python solution which doesn't require multiple writes to disk and launching external processes.  The number of calls to the interpolation function, of separate sets of points and values, can approach 20,000 in the processing I'm performing.</p>
  
  <p>I specifically need to interpolate  for points, so using the IDW function in ArcGIS to generate rasters sounds even worse than using R, in terms of performance.....unless there is a way to efficiently mask out only the points I need. Even with this modification, I wouldn't expect performance to be all that great.  I will look into this option as another alternative. UPDATE:  The problem here is you are  tied to the cell size you are using.  If you reduce the cell-size to get better accuracy, processing takes a long time.  You also need to follow up by extracting by points.....over all an ugly method if you want values for specific points.</p>
  
  <p>I have looked at the <a href="http://docs.scipy.org/doc/scipy/reference/" rel="noreferrer">scipy documentation</a>, but it doesn't look like there is a straight forward way to calculate IDW.</p>
  
  <p>I'm thinking of rolling my own implementation, possibly using some of the scipy functionality to locate the closest points and calculate distances.  </p>
  
  <p>Am I missing something obvious?  Is there a python module I haven't seen that does exactly what I want?  Is creating my own implementation with the aid of scipy a wise choice?</p>