Convert LAZ files to WOLF numpy grids
Attention
This tutorial requires version 2.2.40 or later of wolfhece package.
LAZ files contain point clouds and attributes. These files can be large and are not well suited for processing small or localized arrays.
The Wolf Grid format offers a good alternative for storing and manipulating such data. It uses binary numpy arrays, which can be loaded into memory quickly.
While this format may not be the most compact, it is easy to use and share.
from pathlib import Path
import numpy as np
from wolfhece.lazviewer.laz_viewer import xyz_laz_grids
from wolfhece.pydownloader import toys_dataset
laz1:Path
laz2:Path
# Download two LAZ files from the toys dataset
laz1 = toys_dataset('LAZ', '251500_140750.laz')
laz2 = toys_dataset('LAZ', '251500_141000.laz')
# Create a directory to store the numpy grids
laz_dir = laz1.parent
np_dir = laz_dir.parent / 'Grids_Numpy'
np_dir.mkdir(exist_ok= True)
# Create the grids from the LAZ files
grids = xyz_laz_grids(dir_grids= np_dir, create= True)
grids.create_from_laz(dir_laz= laz_dir, # Path or str to the directory containing the LAZ files
ds = 50., # Grid step in the units of the LAZ files (here meters)
force_format= np.float32) # Force the numpy array format (default is np.float64) --> can save disk space
Note
Alternatively, if data are already processed you can download an existing grid from a public website using the toy dataset function or laz_grid_from_url function.
Data will be downloaded in the ‘data’ directory of wolfhece package.
from wolfhece.pydownloader import toys_laz_grid
grid_dir = toys_laz_grid('LAZ_Numpy', 'example.txt')