Skip to content

Build LiDAR Spatial Index

Builds a .lax spatial index for every LAS/LAZ file in the folder that doesn't have one, and writes it next to the file. With an index, reading part of a file (a tile of a large file, or the buffer strip of a neighbouring file) reads only that area instead of the whole file.

The other LiDAR tools build missing indexes themselves before they process the data (see How the PC2Products Tools Run), so running this tool is optional. It lets you build them ahead of time, because building an index reads every point of the file once:

  • LAZ files are indexed at about 2.3 million points per second per process (the points are decompressed), which is about 80 minutes for 11.5 billion points with one process. LAS files are only read, at about 5.4 million points per second.
  • Several files are indexed at once, one per R process: at most 8, one fewer than the CPU cores, and about one per 200 MB of files. On one hard disk, 118 GB of LAZ (11.5 billion points) took about 24 minutes with 19 processes and 28 minutes with 6, as the disk serves more reads queued at once faster.
  • Each index is small (34 KB for a 20 GB file), and building indexes uses little memory (1.4 GB for 8 processes).

The input folder must be writable. If an index can't be written, the tool prints a warning and reports how many files have an index.

Parameter Type Required Description
in_las_folder directory Yes Folder containing the LAS/LAZ files. The .lax files are written into it.
overwrite bool No Set to True to rebuild the indexes of files that already have one, for example after the files changed. The default is False.
processes int No Most R processes to build indexes with. The default (0) leaves it to the limits above; a value only lowers them, never raises the 8.
from beratools.modules.pc2products.rpy_lidar_index import rpy_lidar_index

rpy_lidar_index(in_las_folder="tests/data/LiDAR")

Command line

bt lidar_index   # show the parameters
bt lidar_index --in_las_folder <las_dir>
bt lidar_index --in_las_folder <las_dir> --overwrite true