{"id":6390,"library":"lazrs","title":"LAZrs - LAZ Compression for Python","description":"LAZrs provides Python bindings for `laz-rs`, a high-performance Rust implementation of LAZ (Laszip) compression and decompression. Its primary role is to serve as an optional, multi-threaded backend for other Python libraries, such as `laspy`, enabling them to efficiently read and write LAZ data. The library is currently at version 0.8.1, with releases tied to updates of its underlying Rust core.","status":"active","version":"0.8.1","language":"en","source_language":"en","source_url":"https://github.com/laz-rs/laz-rs-python","tags":["LAZ","LAS","compression","geospatial","Lidar","Rust","bindings","point cloud"],"install":[{"cmd":"pip install lazrs","lang":"bash","label":"Standard installation"},{"cmd":"pip install laspy[lazrs]","lang":"bash","label":"Install with laspy for LAZ support"}],"dependencies":[],"imports":[],"quickstart":{"code":"import laspy\nimport os\n\n# Create a dummy LAS file for demonstration\nheader = laspy.header.Header()\nheader.point_format.scale = [0.01, 0.01, 0.01]\nheader.point_format.offset = [0, 0, 0]\n\npoints = laspy.create_points(point_count=100)\npoints.x = range(100)\npoints.y = range(100)\npoints.z = range(100)\n\ninput_filename = 'dummy.las'\noutput_filename = 'compressed.laz'\n\nwith laspy.open(input_filename, mode='w', header=header) as writer:\n    writer.write_points(points)\n\nprint(f\"Created {input_filename} with {points.x.shape[0]} points.\")\n\n# --- Using lazrs as a backend via laspy to compress and decompress ---\n# laspy will automatically detect and use lazrs if installed.\n# Explicitly set laz_backend=laspy.compression.LazBackend.Lazrs if needed.\n\n# Compress to LAZ using lazrs (implicitly by laspy)\nwith laspy.open(input_filename, mode='r') as infile:\n    with laspy.open(output_filename, mode='w', header=infile.header) as outfile:\n        outfile.write_points(infile.read_points())\n\nprint(f\"Compressed to {output_filename} using lazrs backend.\")\n\n# Decompress from LAZ using lazrs (implicitly by laspy)\nwith laspy.open(output_filename, mode='r') as reader:\n    decompressed_points = reader.read_points()\n    print(f\"Decompressed {decompressed_points.x.shape[0]} points from {output_filename}.\")\n    assert decompressed_points.x.shape[0] == points.x.shape[0]\n\n# Clean up dummy files\nos.remove(input_filename)\nos.remove(output_filename)\nprint(\"Cleaned up dummy files.\")","lang":"python","description":"LAZrs primarily functions as a high-performance backend for other libraries like `laspy`. This quickstart demonstrates how `laspy` leverages `lazrs` for transparent LAZ file compression and decompression. When `lazrs` is installed, `laspy` automatically uses it for LAZ processing, providing multi-threaded performance. There is no direct high-level API for `lazrs` for file operations; it's consumed implicitly by compatible libraries."},"warnings":[{"fix":"Consider `laszip-python` as an alternative backend for `laspy` if waveform data is critical. Install `laspy` with `pip install laspy[laszip]`.","message":"LAZrs does not support points with waveforms. If your LAZ data includes waveform information, you will need to use an alternative backend like `laszip-python` (if available and compatible with your version of `laspy`) to ensure all data is correctly handled.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use a higher-level library like `laspy` (installed with `laspy[lazrs]`) for reading and writing LAZ files. `lazrs` will be used automatically by `laspy` for performance.","message":"LAZrs is primarily a low-level Rust-based compression engine and offers no direct high-level Python API for file reading or writing. It is consumed as a backend by libraries like `laspy`, meaning users interact with `lazrs` indirectly through the `laspy` API. Attempting to find high-level `lazrs.read()` or `lazrs.write()` functions will be unsuccessful.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When upgrading, thoroughly test existing code. Consult the `laz-rs-python` GitHub repository's commit history for changes if unexpected behavior occurs.","message":"Explicit documentation on breaking changes between major versions (e.g., from 0.5.x to 0.8.x) specifically for the Python bindings is not readily available. While the underlying Rust library may have its own changelog, direct impact on the Python API for non-backend users is unclear.","severity":"gotcha","affected_versions":"0.x to 0.8.x"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}