{"id":45886,"library":"pykrige","title":"PyKrige","description":"PyKrige is a Kriging Toolkit for Python that supports 2D and 3D ordinary and universal kriging, as well as simple kriging, regression kriging, and conditional realizations. It provides a scikit-learn compatible interface and is developed by the GeoStat Framework project. Current version: 1.7.3. Release cadence: irregular, with several updates per year.","status":"active","version":"1.7.3","language":"python","source_language":"en","source_url":"https://github.com/GeoStat-Framework/PyKrige","tags":["kriging","geostatistics","spatial interpolation","variogram"],"install":[{"cmd":"pip install pykrige","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Array operations and mathematical computations.","package":"numpy","optional":false},{"reason":"Spatial distance calculations and optimization routines.","package":"scipy","optional":false},{"reason":"For the sklearn-compatible Kriging interface.","package":"scikit-learn","optional":false}],"imports":[{"note":"Subpackages ok, uk, etc. must be explicit; top-level import raises AttributeError.","wrong":"from pykrige import OrdinaryKriging","symbol":"OrdinaryKriging","correct":"from pykrige.ok import OrdinaryKriging"},{"note":"Same as above; use subpackage import.","wrong":"from pykrige import UniversalKriging","symbol":"UniversalKriging","correct":"from pykrige.uk import UniversalKriging"},{"note":"RegressionKriging replaces older Krige; always use RegressionKriging.","wrong":null,"symbol":"Krige","correct":"from pykrige.rk import RegressionKriging"}],"quickstart":{"code":"import numpy as np\nfrom pykrige.ok import OrdinaryKriging\n\n# Synthetic data\nnp.random.seed(42)\nX = np.random.rand(20, 2) * 10\nZ = np.sin(X[:, 0]) + np.cos(X[:, 1])\n\n# Grid for prediction\ngridx = np.linspace(0, 10, 20)\ngridy = np.linspace(0, 10, 20)\n\n# Ordinary Kriging\nOK = OrdinaryKriging(X[:, 0], X[:, 1], Z, variogram_model='linear')\nz, ss = OK.execute('grid', gridx, gridy)\nprint(z.shape, ss.shape)","lang":"python","description":"Perform ordinary kriging on 2D synthetic data with a linear variogram model."},"warnings":[{"fix":"Use 'linear' or 'spherical' as default; test other models on small datasets first.","message":"Do not use variogram_model='exponential' or 'gaussian' without checking data sparsity; they may produce singular matrix errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'from pykrige.kriging_tools import ...' with 'from pykrige.tools import ...'.","message":"The old pykrige.kriging_tools module is deprecated. Use pykrige.tools instead.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Always pass coordinate_data keyword: model.fit(X, y, coordinate_data=coords).","message":"When using the scikit-learn API, the fit() method requires additional keyword arguments beyond X, y (e.g., coordinates). Incorrect usage leads to unexpected errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.7.3':46 '2d':11 '3d':13 'cadenc':48 'compat':34 'condit':26 'current':44 'develop':38 'framework':42 'geostat':41 'geostatist':56 'interfac':35 'interpol':58 'irregular':49 'krige':5,17,22,24,55 'learn':33 'ordinari':14 'per':53 'project':43 'provid':29 'pykrig':1,2 'python':8 'realiz':27 'regress':23 'releas':47 'scikit':32 'scikit-learn':31 'sever':51 'simpl':21 'spatial':57 'support':10 'toolkit':6 'univers':16 'updat':52 'variogram':59 'version':45 'well':19 'year':54","created_at":"2026-06-07T12:57:13.141930+00:00","updated_at":"2026-06-07T12:57:13.141930+00:00","problems":[{"fix":"Remove duplicate points using numpy.unique or adjust the variogram model (try 'linear').","cause":"The kriging matrix (covariance matrix) is singular, often due to duplicate points or poorly chosen variogram model.","error":"LinAlgError: Matrix is singular."},{"fix":"Use 'from pykrige.ok import OrdinaryKriging'.","cause":"Direct import from top-level pykrige, not from subpackage.","error":"AttributeError: module 'pykrige' has no attribute 'OrdinaryKriging'"},{"fix":"Ensure X is 2D (n_samples, n_features) and coordinate_data is 2D (n_samples, n_dims).","cause":"Mismatch between coordinate array shape and data array shape in sklearn API.","error":"ValueError: The number of coordinates does not match the number of points."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/GeoStat-Framework/PyKrige","github":"https://github.com/GeoStat-Framework/PyKrige","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["analytics","maps"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}