title: How to interpolate 2D spatial data with kriging in Python?
body: <p>I have a spatial 2D domain, say [0,1]×[0,1]. In this domain, there are 6 points where some scalar quantity of interest has been observed (e.g., temperature, mechanical stress, fluid density, etc.). How can I predict the quantity of interest at unobserved points? In other words, how may I interpolate spatial data in Python?</p>
  <p>For example, consider the following coordinates for points in the 2D domain (inputs) and corresponding observations of the quantity of interest (outputs).</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  coordinates = np.array([[0.0,0.0],[0.5,0.0],[1.0,0.0],[0.0,1.0],[0.5,1.],[1.0,1.0]])
  observations = np.array([1.0,0.5,0.75,-1.0,0.0,1.0])
  </code></pre>
  <p>The X and Y coordinates can be extracted with:</p>
  <pre class="lang-py prettyprint-override"><code>x = coordinates[:,0]
  y = coordinates[:,1]
  </code></pre>
  <p>The following script creates a scatter plot where yellow (resp. blue) represents high (resp. low) output values.</p>
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  fig = plt.figure()
  plt.scatter(x, y, c=observations, cmap='viridis')
  plt.colorbar()
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7bdVz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7bdVz.png" alt="Observations at 6 points" /></a></p>
  <p>I would like to use Kriging to predict the scalar quantity of interest on a regular grid within the 2D input domain. How can I do this in Python?</p>