Python bindings for LASR library - Fast Airborne LiDAR Data Processing
Project description
LASR Python Bindings
Python bindings for the LASR (pronounced "laser") library - a high-performance LiDAR point cloud processing library.
Overview
The LASR Python bindings provide a clean, Pythonic interface to the powerful LASR C++ library for processing large-scale LiDAR point clouds. The API closely mirrors the R API, ensuring consistency across language bindings.
Features
- High Performance: Direct bindings to optimized C++ code
- Complete API Coverage: All LASR stages and operations available
- Pythonic Interface: Natural Python syntax with operator overloading
- Pipeline Processing: Chain operations for efficient processing
- Multi-threading Support: Leverage multiple cores for processing
- Memory Efficient: Minimal memory overhead through C++ backend
- Rich Results: Access detailed stage outputs and processing statistics
- Structured Error Handling: Comprehensive error information and debugging
- Flexible Input Paths: Pass a directory/catalog or an iterable of path-like objects; only .las/.laz files are used
Installation
Prerequisites
- Python 3.9+
- pybind11
- C++17 compatible compiler
- GDAL (>= 2.2.3)
- GEOS (>= 3.4.0)
- PROJ (>= 4.9.3)
Build from Source
cd python
pip install -e .
or using setuptools directly:
cd python
python setup.py build_ext --inplace
Quick Start
import pylasr
# Create a simple processing pipeline
pipeline = (pylasr.info() +
pylasr.classify_with_sor(k=10) +
pylasr.delete_points(["Classification == 18"]) +
pylasr.write_las("cleaned.las"))
# Set processing options
pipeline.set_concurrent_points_strategy(4)
pipeline.set_progress(True)
# Execute pipeline (returns rich results)
files = ["input.las", "input2.las"]
result = pipeline.execute(files)
API Structure
Core Classes
Pipeline
Container for multiple stages with execution management.
# Create empty pipeline
pipeline = pylasr.Pipeline()
# Add stages
pipeline += pylasr.info()
pipeline += pylasr.classify_with_sor()
# Set processing strategy
pipeline.set_concurrent_files_strategy(2)
# Execute pipeline
result = pipeline.execute(["file1.las", "file2.las"])
Processing Strategies
LASR supports different parallelization strategies:
# Sequential processing
pipeline.set_sequential_strategy()
# Concurrent points (single file, multiple cores)
pipeline.set_concurrent_points_strategy(ncores=4)
# Concurrent files (multiple files, single core each)
pipeline.set_concurrent_files_strategy(ncores=2)
# Nested strategy (multiple files, multiple cores each)
pipeline.set_nested_strategy(ncores1=2, ncores2=4)
Available Stages
Input/Reading
reader()- Basic point cloud readerreader_coverage()- Read points from coverage areareader_circles()- Read points within circular areasreader_rectangles()- Read points within rectangular areas
Classification & Filtering
classify_with_sor()- Statistical Outlier Removal classificationclassify_with_ivf()- Isolated Voxel Filter classificationclassify_with_csf()- Cloth Simulation Filter (ground classification)delete_points()- Remove points by filter criteriadelete_noise()- Remove noise points (convenience function)delete_ground()- Remove ground points (convenience function)filter_with_grid()- Grid-based point filtering
Point Operations & Attributes
edit_attribute()- Modify point attribute valuesadd_extrabytes()- Add custom attributes to pointsadd_rgb()- Add RGB color informationremove_attribute()- Remove attributes from pointssort_points()- Sort points spatially for better performancetransform_with()- Transform points using raster operations
Sampling & Decimation
sampling_voxel()- Voxel-based point samplingsampling_pixel()- Pixel-based point samplingsampling_poisson()- Poisson disk sampling for uniform distribution
Rasterization & Gridding
rasterize()- Convert points to raster grids (DTM, DSM, CHM, etc.)rasterize_triangulation()- Rasterize triangulated surfacesfocal()- Apply focal operations on rasterspit_fill()- Fill pits in canopy height models
Geometric Analysis & Features
geometry_features()- Compute geometric features (eigenvalues, etc.)local_maximum()- Find local maxima in point cloudslocal_maximum_raster()- Find local maxima in rasters (tree detection)triangulate()- Delaunay triangulation of pointshulls()- Compute convex hulls
Segmentation & Tree Detection
region_growing()- Region growing segmentation for tree detection
Data Loading & Transformation
load_raster()- Load external raster dataload_matrix()- Load transformation matrices
I/O Operations
write_las()- Write LAS/LAZ fileswrite_copc()- Write Cloud Optimized Point Cloud fileswrite_pcd()- Write Point Cloud Data fileswrite_vpc()- Write Virtual Point Cloud catalogswrite_lax()- Write spatial index files
Coordinate Systems
set_crs()- Set coordinate reference system
Information & Analysis
info()- Get point cloud information and statisticssummarise()- Generate summary statistics
Utility & Development
callback()- Custom callback functions for advanced processingnothing()- No-operation stage for debuggingstop_if_outside()- Stop processing if outside boundsstop_if_chunk_id_below()- Conditional processing based on chunk ID
Comparison with R API
The Python API closely mirrors the R API structure:
| R | Python |
|---|---|
exec(pipeline, on = files) |
pipeline.execute(files) |
pipeline + stage |
pipeline + stage |
with = list(ncores = 4) |
pipeline.set_concurrent_points_strategy(4) |
filter = "Z > 10" |
filter = ["Z > 10"] |
Contributing
See the main LASR repository for contribution guidelines.
License
GPL-3 - see LICENSE file for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylasr-0.17.2-cp311-cp311-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: pylasr-0.17.2-cp311-cp311-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 46.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2320baa46e928d90084f1295483a22b3e52a1d36be162968c7e879414926b175
|
|
| MD5 |
48866f1dbaa8da361966cd8f5f52d9b1
|
|
| BLAKE2b-256 |
9b7a4150fc62bdf08f14fa35e3d11ff007952d8bc85917368c50c9a62f3d73fe
|