.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00_ordinary.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_00_ordinary.py: Ordinary Kriging Example ======================== First we will create a 2D dataset together with the associated x, y grids. .. GENERATED FROM PYTHON SOURCE LINES 8-28 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import pykrige.kriging_tools as kt from pykrige.ok import OrdinaryKriging data = np.array( [ [0.3, 1.2, 0.47], [1.9, 0.6, 0.56], [1.1, 3.2, 0.74], [3.3, 4.4, 1.47], [4.7, 3.8, 1.74], ] ) gridx = np.arange(0.0, 5.5, 0.5) gridy = np.arange(0.0, 5.5, 0.5) .. GENERATED FROM PYTHON SOURCE LINES 29-36 Create the ordinary kriging object. Required inputs are the X-coordinates of the data points, the Y-coordinates of the data points, and the Z-values of the data points. If no variogram model is specified, defaults to a linear variogram model. If no variogram model parameters are specified, then the code automatically calculates the parameters by fitting the variogram model to the binned experimental semivariogram. The verbose kwarg controls code talk-back, and the enable_plotting kwarg controls the display of the semivariogram. .. GENERATED FROM PYTHON SOURCE LINES 36-46 .. code-block:: Python OK = OrdinaryKriging( data[:, 0], data[:, 1], data[:, 2], variogram_model="linear", verbose=False, enable_plotting=False, ) .. GENERATED FROM PYTHON SOURCE LINES 47-50 Creates the kriged grid and the variance grid. Allows for kriging on a rectangular grid of points, on a masked rectangular grid of points, or with arbitrary points. (See OrdinaryKriging.__doc__ for more information.) .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python z, ss = OK.execute("grid", gridx, gridy) .. GENERATED FROM PYTHON SOURCE LINES 54-55 Writes the kriged grid to an ASCII grid file and plot it. .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python kt.write_asc_grid(gridx, gridy, z, filename="output.asc") plt.imshow(z) plt.show() .. image-sg:: /examples/images/sphx_glr_00_ordinary_001.png :alt: 00 ordinary :srcset: /examples/images/sphx_glr_00_ordinary_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.037 seconds) .. _sphx_glr_download_examples_00_ordinary.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00_ordinary.ipynb <00_ordinary.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00_ordinary.py <00_ordinary.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 00_ordinary.zip <00_ordinary.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_