DataSetFilters.remove_points

DataSetFilters.remove_points#

DataSetFilters.remove_points(
ind: int | VectorLikeInt | VectorLikeBool,
mode: Literal['any', 'all'] = 'any',
*,
invert: bool = False,
pass_point_ids: bool = True,
pass_cell_ids: bool = True,
inplace: bool = False,
progress_bar: bool = False,
) → _OutputDataSet[source]#

Remove points and their cells from a mesh.

Cells are removed according to mode, and only points used by a remaining cell are kept. The output is PolyData for PolyData input, PointSet for PointSet input, and an UnstructuredGrid otherwise. With invert=True and mode='all' this removes every point except those specified, which is extract_points() with the input type kept:

# UnstructuredGrid, whatever the input
extracted = mesh.extract_points(ind)

# PolyData for PolyData input, PointSet for PointSet input
extracted = mesh.remove_points(ind, mode='all', invert=True)

A PolyData without cells returns one vertex cell per remaining point, the same as pv.PolyData(points) creates. Use cast_to_pointset() first to remove points from a point cloud without cells.

Added in version 0.49.

Parameters:
indint | VectorLikeInt | VectorLikeBool

Point indices to remove. Can be a single int or a vector of ints. A bool vector is also supported; the vector size should match the number of points.

mode‘any’ | ‘all’, default: ‘any’

Remove cells that use 'any' of the specified points, or only cells whose points are 'all' specified. With 'all', specified points that are still used by a remaining cell are kept.

invertbool, default: False

Invert the selection and remove all points except those specified.

pass_point_idsbool, default: True

Add a point array 'vtkOriginalPointIds' that identifies the original points the remaining points correspond to.

pass_cell_idsbool, default: True

Add a cell array 'vtkOriginalCellIds' that identifies the original cells the remaining cells correspond to.

inplacebool, default: False

Update the mesh in-place. This is only possible when the output has the same type as the input.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.UnstructuredGrid | pyvista.PolyData | pyvista.PointSet

Mesh with the specified points removed.

Examples#

Download Python source code | Download Jupyter notebook

Remove 150 points from a sphere.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> reduced_sphere = sphere.remove_points(ind=range(100, 250))
>>> reduced_sphere.plot(show_edges=True, line_width=3)
../../../_images/pyvista-DataSetFilters-remove_points-0fe5bf2a8b267668_00_00.png

Remove a point from a mesh of line segments. The ids of the remaining points are kept.

>>> points = [
...     [0.0, 0.0, 0.0],
...     [1.0, 0.0, 0.0],
...     [2.0, 0.0, 0.0],
...     [3.0, 0.0, 0.0],
... ]
>>> lines = pv.PolyData(points, lines=[2, 0, 1, 2, 1, 2, 2, 2, 3])
>>> reduced = lines.remove_points(ind=0)
>>> reduced['vtkOriginalPointIds'].tolist()
[1, 2, 3]

See Also#

extract_points, remove_cells