Like the filters.programmable filter, the predicate filter applies a Python function to a stream of points. Points can be retained/removed from the stream by setting true/false values into a special “Mask” dimension in the output point array.


See filters.programmable for documentation about how to access the metadata, spatialreference, and schema variables.

import numpy as np

def filter(ins,outs):
   cls = ins['Classification']

   keep_classes = [1,2]

   # Use the first test for our base array.
   keep = np.equal(cls, keep_classes[0])

   # For 1:n, test each predicate and join back
   # to our existing predicate array
   for k in range(1,len(keep_classes)):
       t = np.equal(cls, keep_classes[k])
       keep = keep + t

   outs['Mask'] = keep
   return True

The example above sets the “mask” to true for points that are in classifications 1 or 2 and to false otherwise, causing points that are not classified 1 or 2 to be dropped from the point stream.


filters.range is a specialized filter that implements the exact functionality described in this Python operation. It is likely to be much faster than Python, but not as flexible. filters.predicate and filters.programmable are tools you can use for prototyping point stream processing operations.

See also

If you want to just read a Pipeline of operations into a numpy array, the PDAL Python extension might be what you want. See it at




When reading a function from a separate Python file, the file name to read from. [Example:]
The Python module that is holding the function to run. [Required]
The function to call.
A JSON dictionary of items you wish to pass into the modules globals as the pdalargs object.