Remove dataset points via programmable filter

Dear all,

I am trying to remove points from a dataset based on geometrical conditions. In order to do so I have to get the coordinates of the dataset, select which ones fulfill my conditions and then generate a new dataset with different number of pointData. I tried an approach like this one:

import vtk
from vtkmodules.vtkCommonDataModel import vtkDataSet
import vtk.numpy_interface.dataset_adapter as dsa
import numpy as np

x_old    = inputs[0].GetPointData().GetArray('x')
z_old    = inputs[0].GetPointData().GetArray('z')


for i in range(len(x_old)) :
	if x_old[i]>0.12 :   

output.PointData.append(x_new, 'x_new')
output.PointData.append(z_new, 'z_new')

However I think that I am having errors because the length of x_new is not the same as the initial one (x_old). How could I generate a new dataset with some of the previous data points with their respective arrays? Thank you in advance!

Is there any example of generating unstructured data from a set of coordinates in python? I couldn’t find an example like this.