Install & Compatibility
Where this runs
tested against v2.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
96MB installed
● package 96MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
File
✓ laspy.read('file.las')
✗ from laspy.file import File; infile = File('file.las', mode='r')
The `laspy.file.File` class was removed in `laspy` 2.0.0 and replaced with `laspy.read()` which returns a `LasData` object.
This quickstart demonstrates how to create a simple LAS file from scratch, read an existing LAS file using `laspy.open()` and `LasData.read()`, access point data and header attributes, and filter points. It also shows how to write new or modified `LasData` objects to a new file. Note the distinction between scaled (lowercase) and raw (uppercase) dimension access.
import laspy
import numpy as np
import os
# Create a dummy LAS file for demonstration
header = laspy.LasHeader(point_format=3, version="1.4")
header.offsets = np.array([0, 0, 0])
header.scales = np.array([0.01, 0.01, 0.01])
las_data = laspy.LasData(header)
n_points = 100
las_data.x = np.random.rand(n_points) * 100
las_data.y = np.random.rand(n_points) * 100
las_data.z = np.random.rand(n_points) * 50
las_data.classification = np.random.randint(0, 5, n_points)
output_filename = "output.las"
las_data.write(output_filename)
print(f"Created {output_filename} with {len(las_data.points)} points.")
# Read a LAS/LAZ file
try:
with laspy.open(output_filename) as fh:
print(f"Reading {fh.header.point_count} points from {output_filename}")
las = fh.read()
# Access point data (scaled and raw)
print(f"X (scaled): {las.x[:5]}") # Scaled coordinates
print(f"X (raw): {las.X[:5]}") # Raw integer coordinates
print(f"Classification: {las.classification[:5]}")
# Access header information
print(f"LAS Version: {las.header.version}")
print(f"Point Format ID: {las.header.point_format.id}")
print(f"Offset: {las.header.offsets}")
print(f"Scale: {las.header.scales}")
# Filter points (e.g., classification == 2)
ground_points = las.points[las.classification == 2]
print(f"Number of ground points (classification=2): {len(ground_points)}")
# Create a new LAS file with filtered points
new_las = laspy.create(point_format=las.header.point_format, file_version=las.header.version)
new_las.points = ground_points
filtered_output_filename = "filtered_output.las"
new_las.write(filtered_output_filename)
print(f"Created {filtered_output_filename} with {len(new_las.points)} filtered points.")
finally:
# Clean up dummy files
if os.path.exists(output_filename):
os.remove(output_filename)
if os.path.exists(filtered_output_filename):
os.remove(filtered_output_filename)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'laspy'
The 'laspy' library is not installed in the Python environment you are currently using.
fixInstall the library using pip: `pip install laspy`
laspy.errors.LaspyException: No LazBackend selected, cannot decompress data.
You are attempting to read a compressed LAZ file without having a LAZ backend (like `lazrs` or `laszip`) installed alongside laspy.
fixInstall laspy with a LAZ backend. For example: `pip install 'laspy[lazrs]'` or `pip install 'laspy[laszip]'` (or both with `pip install 'laspy[lazrs,laszip]'`).
AttributeError: module 'laspy' has no attribute 'read'
This error occurs when using an outdated syntax to read LAS/LAZ files. In laspy 2.x, the `laspy.read()` function is used directly from the top-level module, replacing older methods like `laspy.file.File()` or `laspy.File()`.
fixUse the modern `laspy.read()` function: `import laspy; las_data = laspy.read('your_file.las')` AttributeError: 'numpy.ndarray' object has no attribute 'append'
You are trying to use a list's `append` method on a NumPy array, which does not have this method. This often happens when attempting to add points or dimensions to `laspy` data structures.
fixWhen modifying point data, treat dimensions as NumPy arrays. To add new points, concatenate arrays or reassign the entire dimension. To add a new dimension, define it first in the point format, then assign a NumPy array of data. Example for adding a new dimension 'new_dim':
```python
import laspy
import numpy as np
# Assuming 'las' is an existing LasData object
# Define the new dimension (e.g., as an unsigned 8-bit integer)
las.add_extra_dims([laspy.ExtraBytesParams(name='new_dim', type=np.uint8)])
# Assign data to the new dimension
las.new_dim = np.zeros(len(las.points), dtype=np.uint8)
```
Upgrade
Version history
2.7.0latest on PyPI · released Jan 14, 2026
Audit
Dependencies
numpyrequiredCore dependency for array-based point data manipulation.
lazrsoptionalOptional backend for LAZ compression/decompression, generally faster due to multi-threading. Required for COPC support.
laszip-pythonoptionalOptional backend for LAZ compression/decompression, official implementation, supports waveform data.
pyprojoptionalOptional, for Coordinate Reference System (CRS) / Spatial Reference System (SRS) handling.
requestsoptionalOptional, enables CopcReader to handle COPC files from HTTP servers.
richoptionalRequired for the optional command-line interface (CLI) features.
typeroptionalRequired for the optional command-line interface (CLI) features.