import numpy as np
import pdal
# Numpy array to be used as buffer
in_buffer = np.zeros(max_chunk_size, dtype=[("X", float), ("Y", float), ("Z", float)])
# The function to populate the buffer iteratively
def load_next_chunk() -> int:
"""
Function called by PDAL before reading the data from the buffer.
IMPORTANT: must return the total number of items to be read from the buffer.
The Pipeline execution will keep calling this function in a loop until 0 is returned.
"""
#
# Replace here with your code that populates the buffer and returns the number of elements to read
#
chunk_size = next_chunk.size
in_buffer[:chunk_size]["X"] = next_chunk[:]["X"]
in_buffer[:chunk_size]["Y"] = next_chunk[:]["Y"]
in_buffer[:chunk_size]["Z"] = next_chunk[:]["Z"]
return chunk_size
# Configure input array and handler during Pipeline initialization...
p = pdal.Pipeline(pipeline_json, arrays=[in_buffer], stream_handlers=[load_next_chunk])
# ...alternatively you can use the setter on an existing Pipeline
# p.inputs = [(in_buffer, load_next_chunk)]