{"id":9067,"library":"laszip","title":"LASzip Python Bindings","description":"The `laszip` library provides Python bindings for the LASzip C/C++ library, enabling efficient compression and decompression of LAZ (compressed LAS) point cloud files. It leverages `pybind11` for seamless integration. The current version is 0.3.0, and releases occur as needed for bug fixes and feature enhancements, typical for a pre-1.0 library.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/LASzip/laszip-python","tags":["gis","lidar","compression","spatial","point cloud"],"install":[{"cmd":"pip install laszip","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"LaszipReader","correct":"from laszip import LaszipReader"},{"symbol":"LaszipWriter","correct":"from laszip import LaszipWriter"},{"symbol":"LaszipHeader","correct":"from laszip import LaszipHeader"},{"symbol":"LaszipPoint","correct":"from laszip import LaszipPoint"}],"quickstart":{"code":"import laszip\nimport os\nimport tempfile\n\n# Create a temporary file path\ntemp_laz_path = os.path.join(tempfile.gettempdir(), \"test_laszip_quickstart.laz\")\n\ntry:\n    # 1. Prepare a minimal header for writing\n    header = laszip.LaszipHeader()\n    header.major_version = 1\n    header.minor_version = 4\n    header.point_data_format = 6  # Standard LAS 1.4, Point Data Record Format 6\n    header.point_data_record_length = 36 # bytes for format 6\n    header.number_of_point_records = 1\n    header.X_offset = 0.0; header.Y_offset = 0.0; header.Z_offset = 0.0\n    header.X_scale_factor = 0.01; header.Y_scale_factor = 0.01; header.Z_scale_factor = 0.01\n    header.min_x = 100.0; header.max_x = 100.0\n    header.min_y = 200.0; header.max_y = 200.0\n    header.min_z = 300.0; header.max_z = 300.0\n\n    # Prepare a dummy point\n    point = laszip.LaszipPoint()\n    point.X = 10000; point.Y = 20000; point.Z = 30000 # Scaled by 0.01\n    point.classification = 1\n    point.intensity = 100\n\n    # 2. Write a dummy LAZ file\n    print(f\"Writing dummy LAZ to {temp_laz_path}\")\n    with laszip.LaszipWriter(temp_laz_path, header_in=header) as writer:\n        writer.write_point(point)\n\n    # 3. Read the LAZ file back\n    print(f\"Reading from {temp_laz_path}\")\n    with laszip.LaszipReader(temp_laz_path) as reader:\n        read_header = reader.header\n        print(f\"  Read header - Point count: {read_header.number_of_point_records}\")\n        read_point = reader.read_point()\n        print(f\"  Read point: X={read_point.X}, Y={read_point.Y}, Z={read_point.Z}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # 4. Clean up the temporary file\n    if os.path.exists(temp_laz_path):\n        os.remove(temp_laz_path)\n        print(f\"Cleaned up {temp_laz_path}\")","lang":"python","description":"This quickstart demonstrates how to create a minimal LAZ file with a single point and then read it back using `laszip.LaszipWriter` and `laszip.LaszipReader`. It sets up a temporary file to ensure the example is runnable without pre-existing data."},"warnings":[{"fix":"Pin the library version in your `requirements.txt` (e.g., `laszip==0.3.0`) and review release notes/changelogs carefully before updating.","message":"As a pre-1.0.0 library, `laszip`'s API may undergo breaking changes without a major version increment. Always consult the GitHub repository for the latest API documentation and examples when upgrading.","severity":"breaking","affected_versions":"All versions < 1.0.0"},{"fix":"Prioritize `pip install laszip` to use pre-compiled wheels. If building from source, ensure you have a compatible C++ compiler (GCC, Clang, MSVC) and `pip install pybind11` (or `pip install 'pybind11[global]'`) and necessary system development libraries.","message":"Building `laszip` from source (e.g., if pre-compiled wheels are not available for your platform/Python version) requires C++ build tools and `pybind11` development headers. This can lead to complex build errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Process points in chunks or iterate through them one by one using `reader.read_point()` rather than attempting to store an entire dataset in a list or array. Leverage Python's generator patterns for efficiency.","message":"When processing extremely large point clouds, be mindful of memory consumption if you attempt to load all points into memory simultaneously. `LaszipReader` is designed for iterative reading.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install laszip` to install the library.","cause":"The `laszip` library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'laszip'"},{"fix":"Verify that the file path is correct and the file exists. Use an absolute path or ensure your working directory is correct.","cause":"You are trying to open a LAZ file that does not exist at the specified path.","error":"OSError: [Errno 2] No such file or directory: 'your_non_existent_file.laz'"},{"fix":"Ensure all required `LaszipHeader` fields are correctly populated and consistent with the LAS format specification before creating the writer. Refer to the quickstart example for a minimal valid header.","cause":"The `LaszipHeader` object passed to `LaszipWriter` is malformed or contains invalid values (e.g., `point_data_format` not set, incorrect `point_data_record_length`).","error":"RuntimeError: error creating writer: ... (followed by details like 'invalid header')"},{"fix":"Access the header directly via the `reader.header` attribute after initializing `LaszipReader`. For example: `with laszip.LaszipReader('file.laz') as reader: my_header = reader.header`.","cause":"You're attempting to access a method that either doesn't exist or has changed its name. The header is typically accessed as an attribute (`reader.header`) after opening the reader, not via a `read_header()` method.","error":"AttributeError: 'LaszipReader' object has no attribute 'read_header'"}]}