sample_over_line

RectilinearGrid.sample_over_line(pointa, pointb, resolution=None, tolerance=None, progress_bar=False)

Sample a dataset onto a line.

Parameters
pointasequence

Location in [x, y, z].

pointbsequence

Location in [x, y, z].

resolutionint, optional

Number of pieces to divide line into. Defaults to number of cells in the input mesh. Must be a positive integer.

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.

progress_barbool, optional

Display a progress bar to indicate progress.

Returns
pyvista.PolyData

Line object with sampled data from dataset.

Examples

Sample over a plane that is interpolating a point cloud.

>>> import pyvista
>>> import numpy as np
>>> np.random.seed(12)
>>> point_cloud = np.random.random((5, 3))
>>> point_cloud[:, 2] = 0
>>> point_cloud -= point_cloud.mean(0)
>>> pdata = pyvista.PolyData(point_cloud)
>>> pdata['values'] = np.random.random(5)
>>> plane = pyvista.Plane()
>>> plane.clear_data()
>>> plane = plane.interpolate(pdata, sharpness=3.5)
>>> sample = plane.sample_over_line((-0.5, -0.5, 0), (0.5, 0.5, 0))
>>> pl = pyvista.Plotter()
>>> _ = pl.add_mesh(pdata, render_points_as_spheres=True, point_size=50)
>>> _ = pl.add_mesh(sample, scalars='values', line_width=10)
>>> _ = pl.add_mesh(plane, scalars='values', style='wireframe')
>>> pl.show()
../../../_images/pyvista-RectilinearGrid-sample_over_line-1_00_00.png