Fast Airborne LiDAR Data Processing
The lasr library (pronounced "laser") is a C++ library for large scale airborne point cloud processing with C++, R and Python APIs. It enables the creation and execution of complex processing pipelines on massive lidar data. It can read and write .las, .laz, .copc.laz (local and remote storage) and .pcd files, compute metrics using an area-based approach, generate digital canopy models, segment individual trees, decimate point data, and process collections of files using multicore processing strategies.
lasr offers a range of tools to process massive volumes of lidar data efficiently in a production environment using either the C++ API, the R API (lasR package) or the Python API (pylasr package).
💵 Sponsor lasr. It is free and open source, but requires time and effort to develop and maintain.
lasR in R.The most comprehensive source of documentation is the R package lasR documentation,
as lasr is primarily an R package. Even Python users should start with the R tutorial, while the examples are written in R, the tutorial is more about the general concepts than about coding.
There is no current plan to release lasR on CRAN. Instead, it is hosted on r-universe:
install.packages('lasR', repos = 'https://r-lidar.r-universe.dev')
Since lasR is not available on CRAN, users cannot rely on the CRAN versioning system or the RStudio update button to get the latest version. Instead, when lasR is loaded with library(lasR), an internal routine checks for the latest version and notifies the user if an update is available. This approach allows for more frequent updates, ensuring users have access to the newest features and bug fixes without waiting for a formal release cycle.
library(lasR)
#> lasR 0.1.3 is now available. You are using 0.1.1
#> install.packages('lasR', repos = 'https://r-lidar.r-universe.dev')
pylasr is the Python API for lasr, providing a clean, Pythonic interface to the high-performance C++ library for processing large-scale LiDAR point clouds.
Prerequisites
Build from source
git clone https://github.com/r-lidar/lasR.git
cd lasR/python
pip install -e .
Pre-built packages will be available on PyPI in the future. For now, please build from source.
To use lasr in a C++ program, it must be linked to gdal and proj. Other dependencies are provided in the vendor directory. Tools available to the public are given in api.h.
Below is a simple example of a pipeline that classifies and removed outliers before to produce a Digital Surface Model and a Digital Terrain Model from a folder containing airborne LiDAR point clouds. For more examples see the tutorial.
library(lasR)
folder = "/folder/of/laz/tiles/"
pipeline = classify_with_sor() + delete_noise() + chm(1) + dtm(1)
exec(pipeline, on = folder, ncores = 16, progress = TRUE)
import pylasr
folder = "/folder/of/laz/tiles/"
pipeline = (pylasr.classify_with_sor() +
pylasr.delete_points(["Classification == 18"]) +
pylasr.dsm(1, "dsm.tif") +
pylasr.dtm(1, "dtm.tif"))
pipeline.set_progress(True)
pipeline.set_concurrent_files_strategy(16)
result = pipeline.execute(folder)
The C++ API is significantly more complex to use. The R and Python APIs aim to provide high-level interfaces in high-level languages, making usages simpler and more user-friendly. The low-level C++ API was never intended for standalone use; instead, it serves as a bridge for building other high-level APIs.
#include "api.h"
using namespace api;
std::string on = "/folder/of/laz/tiles/"
// platform independent tmp files
std::filesystem::path temp_dir = std::filesystem::temp_directory_path();
std::filesystem::path temp_dsm = temp_dir / "dsm.tif";
std::filesystem::path temp_dtm = temp_dir / "dtm.tif";
Pipeline tri = triangulate(0, {"Classification %in% 2 9"});
Pipeline dtm = rasterize_triangulation(tri.get_stages().front().get_uid(), 1, temp_dtm.string());
Pipeline p;
p += classify_with_sor();
p += delete_points({"Classification == 18"});
p += rasterize(1, 1, {"max"}, {""}, temp_dsm.string());
p += tri;
p += dtm;
p.set_files(on);
p.set_concurrent_files_strategy(8);
p.set_progress(false);
std::string file = p.write_json();
return execute(file);
lidR
The following benchmark compares the time and RAM usage of lasR (R API) and lidR for producing a Digital Terrain Model (DTM), a Canopy Height Model (CHM), and a raster containing two metrics derived from elevation (Z) and intensity. The test was conducted on 120 million points stored in 4 LAZ files. For more details, check out the benchmark vignette.

lasR introduces pipelines to optimally chain multiple operations on a point cloud, a feature not available in lidR.lasR uses more powerful algorithms designed for speed and efficiency.lasR has no R code except for the API interface. This makes it highly optimized for performance.lidR, which loads the point cloud into an R data.frame, lasR stores point clouds in a C++ structure that is not exposed to the user, minimizing memory usage.lasR has a single strong dependency on gdal. If sf and terra are installed, the user experience is enhanced, but they are not mandatory.For more details, see the relevant vignette.
lasr is free and open source and relies on other free and open source tools.
lasr:
lasR (R bindings):
pylasr (Python bindings):
LASlib and LASzip:
chm_prep:
json parser:
delaunator:
Eigen:
Cloth Simulation Filter (CSF)
Incremental Delaunay
nanoflann
lasr is developed openly by r-lidar.
The initial development of lasr was made possible through the financial support of Laval University. To continue the development of this free software, we now offer consulting, programming, and training services. For more information, please visit our website.
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libgdal-dev libgeos-dev libproj-dev