First, create a TileDB config file tiledb.config where you can set any TileDB configuration parameter (e.g., AWS keys if you would like to write to a TileDB array on S3). Make sure you also add the following, as currently TileDB does not handle duplicate points (this will change in a future version).
Then create a PDAL pipeline to translate some LAS data to a TileDB array, by storing the following in a file called pipeline.json:
You can execute the pipeline with PDAL that will carry out the ingestion as follows:
pdal pipeline -i pipeline.json
We now have points and attributes stored in an array called sample_array. This write uses the streaming mode of PDAL.
You can view this sample_array directly from TileDB as follows (we demonstrate using TileDB's Python API, but any other API would work as well):
import numpy as np
ctx = tiledb.Ctx()
# Open the array and read from it.
with tiledb.SparseArray('sample_array', ctx=ctx, mode='r')as arr:
# Get non-empty domain
# note that the attributes have different types
data = arr[:]
coords = np.array([np.asarray(list(t))for t in data['coords']])
v = pptk.viewer(coords, coords[:,2])
PDAL is single-threaded, but coupled with TileDB's parallel write support, can become a powerful tool for ingesting enormous amounts of point cloud data into TileDB. The PDAL driver supports appending to an existing dataset and we use this with Dask to create a parallel update.
We demonstrate parallel ingestion with the code below. Make sure to remove or move the sample_array created in the previous example.
Although the TileDB driver is parallel (i.e., it uses multiple threads for decompression and IO), PDAL is single-threaded and therefore some tasks may benefit from additional boosting. Take for instance the following PDAL command that counts the number of points in the dataset using the TileDB driver.
pdal info --driver readers.tiledb --readers.tiledb.array_name=sample_array -i sample_array
We can write a simple script in Python with Dask and direct access to TileDB to perform the same operation completely in parallel: