Skip to main content

pyvista-krige

Kriging for PyVista datasets, powered by PyKrige.

Installing the package adds a krige namespace to every PyVista dataset and plotter through PyVista's extension mechanism. No import is needed.

pip install pyvista-krige            # ordinary and universal kriging, 2D and 3D
pip install "pyvista-krige[all]"     # + GSTools models, regression/classification kriging, CV

Usage

import pyvista as pv
from pyvista import examples

probes = examples.download_thermal_probes()  # 245 points with 'temperature (C)'

# Temperature rises with depth, so krige with a depth drift (universal kriging).
probes['depth'] = probes.points[:, 2]
model = probes.krige.fit(
    'temperature (C)',
    method='universal',
    specified_drift=['depth'],
    variogram_model='exponential',
    max_lag=9000.0,  # fit the variogram to the short lags only
)
grid = pv.ImageData(
    dimensions=(30, 38, 50), spacing=(500, 500, 100), origin=(329700, 4252600, -2700)
)
grid['depth'] = grid.points[:, 2]
kriged = model.predict(grid)  # kriged in memory-bounded chunks
kriged['temperature (C) variance']  # kriging variance at every point

# Score the model on held-out probes.
holdout = model.cross_validate(10)
print(holdout.rmse)

# Or krige straight onto an image spanning the samples.
image = probes.krige.to_image('temperature (C)', dimensions=(40, 40, 20))

pl = pv.Plotter()
pl.add_mesh(kriged.contour(5, scalars='temperature (C)'), opacity=0.5)
pl.krige.add_exceedance(kriged, 'temperature (C)', 150.0, probability=0.9)
pl.krige.add_variogram(model, loc=(0.62, 0.62), size=(0.36, 0.36))
pl.show()

Each image comes from a script in examples/ that runs on one of PyVista's built-in datasets. To regenerate them, run python examples/render_gallery.py.

Subsurface temperature in 3D

examples/thermal_probes.py: 245 thermal probes kriged onto a 57,000-point volume. Temperature rises steadily with depth, so ordinary kriging, which reverts to the mean away from the probes, bends the isotherms back at the edges of the volume. Universal kriging with a depth drift follows the gradient instead. When the 69 deepest probes are predicted from the rest, the error drops from 55.7 °C (ordinary kriging) to 24.7 °C. The top row shows the isotherms, the kriging standard deviation within 2.5 km of a probe (max_distance), and the fitted variogram. The bottom row shows the regions above 150 °C at 50 % and 90 % probability (pl.krige.add_exceedance), the 10-fold hold-out errors (pl.krige.add_residuals), and horizontal and vertical variograms of the depth-trend residuals (samples.krige.variogram(direction=..., detrend=True)).

Thermal probes kriged in 3D

Kriging compared with Gaussian-kernel interpolation

examples/saddle_comparison.py: the 16 sparse points and saddle surface from PyVista's interpolation example, with the points' elevation interpolated back onto the surface and scored against the true elevation. Leave-one-out cross-validation (model.cross_validate('loo')) picks a gaussian variogram. Kriging is about as accurate as the best kernel radius (RMSE 1.23 against 1.15), and it also shows where it is unsure.

Gaussian interpolation compared with kriging

Mount St. Helens from 400 spot elevations

examples/st_helens.py: 5-fold cross-validation picks the variogram, fitted to 20 lags up to 7 km. The elevation is then kriged back onto the full 152,000-point DEM against all 400 samples, in memory-bounded chunks. The largest errors are along the border, where every estimate is extrapolated from samples on one side. The panels show the true and kriged terrain, the variogram, the error, the kriging standard deviation, and pl.krige.add_uncertainty.

St. Helens rebuilt by kriging

What maps to what

PyKrige pyvista-krige
OrdinaryKriging, UniversalKriging, OrdinaryKriging3D, UniversalKriging3D dataset.krige.fit(scalars, method=..., dim=...). 2D or 3D is detected from the samples.
execute('grid' / 'points' / 'masked') model.predict(target). The fast grid path is used for axis-aligned ImageData and RectilinearGrid. Use where= to krige a subset.
variogram fit, lags, semivariance model.variogram, pl.krige.add_variogram(model)
get_statistics, get_epsilon_residuals model.statistics
update_variogram_model model.with_variogram(...), which returns a new model
drift terms specified_drift=['array name'], external_drift=<ImageData>. The matching drift_terms entry is added for you.
GSTools CovModel variogram_model=gs.Matern(dim=3, ...)
(not in PyKrige) variogram of the drift residuals fit(..., method='universal', detrend=True)
(not in PyKrige) fit only short lags fit(..., max_lag=...)
(not in PyKrige) directional variograms dataset.krige.variogram(scalars, direction='vertical'), .fit(model)
(not in PyKrige) k-fold / leave-one-out scoring of any model model.cross_validate(5) or 'loo', pl.krige.add_residuals(holdout)
(not in PyKrige) extrapolation limits predict(..., max_distance=..., max_std=...)
(not in PyKrige) exceedance probability pyvista_krige.exceedance(result, scalars, threshold), pl.krige.add_exceedance(...)
(not in PyKrige) anisotropy geometry pl.krige.add_anisotropy_ellipsoid(model)
RegressionKriging, ClassificationKriging dataset.krige.regression(...), dataset.krige.classify(...)
Krige + GridSearchCV dataset.krige.cross_validate(scalars, param_grid)

Results follow PyVista's filter conventions:

  • A new dataset is returned, and the input is never modified.
  • The estimate goes in point_data[scalars] and the variance in point_data['<scalars> variance'].
  • Points skipped with where=, max_distance= or max_std= get null_value, and a vtkValidPointMask array is written.

Memory

Without n_closest_points, PyKrige builds a dense matrix between the target points and every sample. predict kriges in chunks small enough to keep that matrix under max_memory (1 GB by default). Grids are split into z-slabs (y-rows in 2D), so they keep PyKrige's fast grid path. This matters most for universal kriging, which has no moving window. max_memory=None kriges everything in one call.

Development

pip install -e ".[all]" pytest
pytest

License

MIT

Metadata

Release files for pyvista-krige 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvista-krige 0.1.0
File Size Uploaded Provenance Actions
pyvista_krige-0.1.0.tar.gz 38.9 kB With provenance Details for pyvista_krige-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyvista-krige 0.1.0
File Interpreter ABI Platform Actions
pyvista_krige-0.1.0-py3-none-any.whl Python 3 none any Details for pyvista_krige-0.1.0-py3-none-any.whl

Total release size: 71.7 kB

Release files / pyvista_krige-0.1.0.tar.gz

Download URL pyvista_krige-0.1.0.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0dc770130dc8daa03d5fce58e22e8afb76ce4ca7905128088a947f4369d6843
BLAKE2b-256 checksum
How to use checksums
ce914ff80e0f257e9066de6e4074c30c8e2b59455769d0da324bce3bfbed8f53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pyvista_krige-0.1.0-py3-none-any.whl

Download URL pyvista_krige-0.1.0-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51bee55bf2810e020f9ad7441dff99807e103bae6bd4e64898aed71c11376c23
BLAKE2b-256 checksum
How to use checksums
699b3a17c721c2502d8204e9a3a4bd415fb6fab20b69ceeb57038be3fd6f6a73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pyvista-krige 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyvista_krige-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page