To compress a LiDAR LAZ file to approximately 15 points per square meter using PDAL, you'll primarily use the filters.voxelgrid filter.
The filters.voxelgrid filter works by dividing the point cloud into 3D cells (voxels) of a specified size and then outputting a single point (typically the centroid of all points within that voxel) for each occupied voxel.
The key is to calculate the cell_size needed to achieve your desired density.
Calculating the cell_size
If you want N points per square meter, then each point should ideally represent an area of 1/N square meters.
The side length of a square with area 1/N would be sqrt(1/N).
filters.voxelgrid: This is the core filter for downsampling.
cell_size: The calculated size of the voxels (0.258 meters). PDAL will create one point (the centroid of original points) for every occupied voxel.
writers.las: Writes the processed point cloud to a new LAZ file.
filename: The desired name for your output LAZ file.
compression: Set to true to ensure the output is in LAZ format (compressed).
minor_version: Generally set to 4 for modern LAZ files, which supports more recent LAS specifications.
Run the PDAL pipeline from your command line:
bash
pdal pipeline compress_pipeline.json
Replace input.laz with the actual path to your input file and output_15ppm.laz with your desired output filename.
Important Considerations:
Approximation: The filters.voxelgrid method provides an approximate target density. The exact output density might vary slightly depending on the original point distribution and if areas are completely empty of points. It guarantees at most one point per voxel.
Data Loss: This is a lossy compression method in terms of point count. You are intentionally reducing the number of points.
Attribute Averaging: For most dimensions (like X, Y, Z), filters.voxelgrid will compute the centroid. For other attributes (like Intensity, Classification, RGB), it might average them or pick the value from one of the points within the voxel. This behavior can sometimes be configured (check PDAL documentation for specific versions/options, but centroid for XYZ is standard).
Verification: After running, you can use pdal info to get the point count and bounding box of your output file. Then, calculate the area of the bounding box and divide the total points by that area to get your actual average points per square meter:
bash
pdal info --all output_15ppm.laz
From the output, get count and the bounds (minX, minY, maxX, maxY).
Area = (maxX - minX) * (maxY - minY)Actual_Density = count / Area