No Pyhton wrapper for SetSnap To CellWithClosestPoint() ?

Hello Everyone,

I have an input dataset which is a polydata consisting only of points with associated scalars. I need to resample it at point locations with a second point-only polydata.

I would like to use the nearest neighbor interpolation, but in Python it seems that the method SetSnapToCellWithClosestPoint() is not wrapped for the classes vtkProbeFilter and vtkResampleWithDataSet.

Can anyone confirm this is true? If yes, is there a specific reason for this?

Does anyone have a suggestion for any other approach to nearest neighbor interpolation? (I need to use Python bindings)

Thanks in advance for any suggestion/comment,

Best Regards,


I checked using PointInterpolator adding the line


and this works Ok. I also checked using

  • SnapToCellWithClosestPointOn()
  • SnapToCellWithClosestPointOff()
  • SetSnapToCellWithClosestPoint(True)

All are wrapped OK. I used the vtk master in Linux. So wrapping seems to be Ok.

Hi Andrew,

Thanks for checking. If I try that, I get:

AttributeError: ‘vtkmodules.vtkFiltersPoints.vtkPointInterpolator’ object has no attribute ‘SnapToCellWithClosestPointOn’

dir(resample) does not show in fact the method.

I am using VTK 9.2.6 on Windows 11, with Python 3.6.8 64 bit



I don’t see that method on vtkPointInterpolator, but I do see it on vtkProbeFilter and vtkResampleWithDataSet (both from vtkFiltersCore).


I still get the error for both filters, vtkProbeFilter and vtkResampleWithDataset. The messages look like this:

AttributeError: ‘vtkmodules.vtkFiltersCore.vtkProbeFilter’ object has no attribute ‘SnapToCellWithClosestPointOn’

AttributeError: ‘vtkmodules.vtkFiltersParallelDIY2.vtkPResampleWith’ object has no attribute ‘SnapToCellWithClosestPointOn’

One difference I notice is that your ResampleWithDataset belongs to vtkFiltersCore and mine is under vkFiltersParallelDIY2 (which I am not sure what it is), but I have instantiated the filter simply as: sf = vtk.vtkResampleWithDataSet()

Thanks for any advice,


P.S. I have installed VTK with pip

This code snippet:

import vtk
f = vtk.vtkProbeFilter()
attrib_list = dir(f)
for attr in attrib_list:
print(f"Attribute: {attr}\n")

produces the output below, which does not include any method related to snapping:

Attribute: AbortExecuteOff

Attribute: AbortExecuteOn

Attribute: AddInputConnection

Attribute: AddInputData

Attribute: AddInputDataObject

Attribute: AddObserver

Attribute: BreakOnError



Attribute: CategoricalDataOff

Attribute: CategoricalDataOn

Attribute: ComputeToleranceOff

Attribute: ComputeToleranceOn

Attribute: ConvertTotalInputToPortConnection



Attribute: DebugOff

Attribute: DebugOn

Attribute: DesiredOutputPrecision

Attribute: FastDelete

Attribute: GetAbortExecute

Attribute: GetAddressAsString

Attribute: GetCategoricalData

Attribute: GetCellLocatorPrototype

Attribute: GetClassName

Attribute: GetCommand

Attribute: GetComputeTolerance

Attribute: GetDebug

Attribute: GetErrorCode

Attribute: GetExecutive

Attribute: GetFindCellStrategy

Attribute: GetGlobalWarningDisplay

Attribute: GetImageDataOutput

Attribute: GetInformation

Attribute: GetInput

Attribute: GetInputAlgorithm

Attribute: GetInputArrayInformation

Attribute: GetInputConnection

Attribute: GetInputDataObject

Attribute: GetInputExecutive

Attribute: GetInputInformation

Attribute: GetInputPortInformation

Attribute: GetIsInMemkind

Attribute: GetMTime

Attribute: GetNumberOfGenerationsFromBase

Attribute: GetNumberOfGenerationsFromBaseType

Attribute: GetNumberOfInputConnections

Attribute: GetNumberOfInputPorts

Attribute: GetNumberOfOutputPorts

Attribute: GetObjectDescription

Attribute: GetObjectName

Attribute: GetOutput

Attribute: GetOutputDataObject

Attribute: GetOutputInformation

Attribute: GetOutputPort

Attribute: GetOutputPortInformation

Attribute: GetPassCellArrays

Attribute: GetPassFieldArrays

Attribute: GetPassPointArrays

Attribute: GetPolyDataOutput

Attribute: GetProgress

Attribute: GetProgressObserver

Attribute: GetProgressScale

Attribute: GetProgressShift

Attribute: GetProgressText

Attribute: GetRectilinearGridOutput

Attribute: GetReferenceCount

Attribute: GetReleaseDataFlag

Attribute: GetSource

Attribute: GetSpatialMatch

Attribute: GetStructuredGridOutput

Attribute: GetStructuredPointsOutput

Attribute: GetTolerance

Attribute: GetTotalNumberOfInputConnections

Attribute: GetUnstructuredGridOutput

Attribute: GetUpdateExtent

Attribute: GetUpdateGhostLevel

Attribute: GetUpdateNumberOfPieces

Attribute: GetUpdatePiece

Attribute: GetUsingMemkind

Attribute: GetValidPointMaskArrayName

Attribute: GetValidPoints

Attribute: GlobalWarningDisplayOff

Attribute: GlobalWarningDisplayOn

Attribute: HasExecutive

Attribute: HasObserver





Attribute: INPUT_PORT



Attribute: InitializeObjectBase

Attribute: InvokeEvent

Attribute: IsA

Attribute: IsTypeOf

Attribute: Modified

Attribute: ModifyRequest

Attribute: NewInstance

Attribute: PassCellArraysOff

Attribute: PassCellArraysOn

Attribute: PassFieldArraysOff

Attribute: PassFieldArraysOn

Attribute: PassPointArraysOff

Attribute: PassPointArraysOn

Attribute: ProcessRequest

Attribute: PropagateUpdateExtent

Attribute: Register

Attribute: ReleaseDataFlagOff

Attribute: ReleaseDataFlagOn

Attribute: RemoveAllInputConnections

Attribute: RemoveAllInputs

Attribute: RemoveAllObservers

Attribute: RemoveInputConnection

Attribute: RemoveObserver

Attribute: RemoveObservers


Attribute: SafeDownCast

Attribute: SetAbortExecute

Attribute: SetCategoricalData

Attribute: SetCellLocatorPrototype

Attribute: SetComputeTolerance

Attribute: SetDebug

Attribute: SetDefaultExecutivePrototype

Attribute: SetExecutive

Attribute: SetFindCellStrategy

Attribute: SetGlobalWarningDisplay

Attribute: SetInformation

Attribute: SetInputArrayToProcess

Attribute: SetInputConnection

Attribute: SetInputData

Attribute: SetInputDataObject

Attribute: SetMemkindDirectory

Attribute: SetObjectName

Attribute: SetPassCellArrays

Attribute: SetPassFieldArrays

Attribute: SetPassPointArrays

Attribute: SetProgressObserver

Attribute: SetProgressShiftScale

Attribute: SetProgressText

Attribute: SetReferenceCount

Attribute: SetReleaseDataFlag

Attribute: SetSourceConnection

Attribute: SetSourceData

Attribute: SetSpatialMatch

Attribute: SetTolerance

Attribute: SetValidPointMaskArrayName

Attribute: SpatialMatchOff

Attribute: SpatialMatchOn

Attribute: UnRegister

Attribute: Update

Attribute: UpdateDataObject

Attribute: UpdateExtent

Attribute: UpdateExtentIsEmpty

Attribute: UpdateInformation

Attribute: UpdatePiece

Attribute: UpdateProgress

Attribute: UpdateTimeStep

Attribute: UpdateWholeExtent

Attribute: UsesGarbageCollector

Attribute: class

Attribute: delattr

Attribute: dict

Attribute: dir

Attribute: doc

Attribute: eq

Attribute: format

Attribute: ge

Attribute: getattribute

Attribute: gt

Attribute: hash

Attribute: init

Attribute: init_subclass

Attribute: le

Attribute: lt

Attribute: ne

Attribute: new

Attribute: reduce

Attribute: reduce_ex

Attribute: repr

Attribute: setattr

Attribute: sizeof

Attribute: str

Attribute: subclasshook

Attribute: this

Attribute: vtkname

Attribute: override

Those methods are only in the master branch, they aren’t yet in any releases.

The vtkPointInterpolator with the vtkVoronoiKernel should provide the kind of nearest-neighbor interpolation that you’re looking for.

kernel = vtkVoronoiKernel()

probe = vtkPointInterpolator()


Thank you so much for the information.

Best Regards,