sample

RectilinearGrid.sample(target, tolerance=None, pass_cell_arrays=True, pass_point_data=True, categorical=False, progress_bar=False)

Resample array data from a passed mesh onto this mesh.

This uses vtk.vtkResampleWithDataSet.

Parameters
targetpyvista.DataSet

The vtk data object to sample from - point and cell arrays from this object are sampled onto the nodes of the dataset mesh.

tolerancefloat, optional

Tolerance used to compute whether a point in the source is in a cell of the input. If not given, tolerance is automatically generated.

pass_cell_arraysbool, optional

Preserve source mesh’s original cell data arrays.

pass_point_databool, optional

Preserve source mesh’s original point data arrays.

categoricalbool, optional

Control whether the source point data is to be treated as categorical. If the data is categorical, then the resultant data will be determined by a nearest neighbor interpolation scheme.

progress_barbool, optional

Display a progress bar to indicate progress.

Returns
pyvista.DataSet

Dataset containing resampled data.

Examples

Resample data from another dataset onto a sphere.

>>> import pyvista
>>> from pyvista import examples
>>> mesh = pyvista.Sphere(center=(4.5, 4.5, 4.5), radius=4.5)
>>> data_to_probe = examples.load_uniform()
>>> result = mesh.sample(data_to_probe)
>>> result.plot(scalars="Spatial Point Data")
../../../_images/pyvista-RectilinearGrid-sample-1_00_00.png

See Resampling for more examples using this filter.