DataObjectFilters.point_data_to_cell_data

DataObjectFilters.point_data_to_cell_data#

DataObjectFilters.point_data_to_cell_data(
*,
pass_point_data: bool = False,
categorical: bool = False,
progress_bar: bool = False,
) → _DataSetOrMultiBlockType[source]#

Transform point data into cell data.

Point data are specified per node and cell data specified within cells. Optionally, the input point data can be passed through to the output.

String arrays are excluded from the conversion with a warning. They are passed through to the output when pass_point_data=True.

Parameters:
pass_point_databool, default: False

If enabled, pass the input point data through to the output.

categoricalbool, default: False

Control whether the source point data is to be treated as categorical. If True, histogramming is used to assign the cell data. Specifically, a histogram is populated for each cell from the scalar values at each point, and the bin with the most elements is selected. In case of a tie, the smaller value is selected.

Note

If the point data is continuous, values that are almost equal (within 1e-6) are merged into a single bin. Otherwise, for discrete data the number of bins equals the number of unique values.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
outputDataSet | MultiBlock

Dataset with the point data transformed into cell data. Return type matches input.

Examples#

Download Python source code | Download Jupyter notebook

Color cells by their z coordinates. First, create point scalars based on z-coordinates of a sample sphere mesh. Then convert this point data to cell data. Use a low resolution sphere for emphasis of cell valued data.

First, plot these values as point values to show the difference between point and cell data.

>>> import pyvista as pv
>>> sphere = pv.Sphere(theta_resolution=10, phi_resolution=10)
>>> sphere['Z Coordinates'] = sphere.points[:, 2]
>>> sphere.plot()
../../../_images/pyvista-DataObjectFilters-point_data_to_cell_data-23892cfa43ebb2f6_00_00.png

Now, convert these values to cell data and then plot it.

>>> import pyvista as pv
>>> sphere = pv.Sphere(theta_resolution=10, phi_resolution=10)
>>> sphere['Z Coordinates'] = sphere.points[:, 2]
>>> sphere = sphere.point_data_to_cell_data()
>>> sphere.plot()
../../../_images/pyvista-DataObjectFilters-point_data_to_cell_data-23892cfa43ebb2f6_01_00.png

See Also#

cell_data_to_point_data

Similar transformation applied to cell data.

points_to_cells()

Re-mesh ImageData to a cells-based representation.