擅长:python、mysql、java
<p>看起来<code>mlab.griddata</code>例程可能会在输出数据上引入不必要的附加约束。虽然输入位置可以是任何位置,但是输出位置<a href="http://matplotlib.sourceforge.net/api/mlab_api.html#matplotlib.mlab.griddata" rel="nofollow">must be a regular grid</a>-因为您的示例是在lat/lon空间中,所以您选择的地图投影可能会违反这一点(即x/y中的规则网格不是lat/lon中的规则网格)。在</p>
<p>您可以尝试来自<a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html#scipy.interpolate.griddata" rel="nofollow">SciPy</a>的<code>interpolate.griddata</code>例程作为替代-但是您需要将您的位置变量组合到一个数组中,因为调用签名是不同的:类似于</p>
<pre><code>import scipy.interpolate
data_locations = np.vstack(datalon.ravel(), datalat.ravel()).T
grid_locations = np.vstack(gridlon.ravel(), gridlat.ravel()).T
grid_data = scipy.interpolate.griddata(data_locations, val.ravel(),
grid_locations, method='nearest')
</code></pre>
<p>对于最近邻插值。这会将位置放入一个数组中,数组中有2列对应于您的2个维度。还可能需要在贴图投影的变换空间中执行插值。在</p>