本机 Python ASPRS LAS 读/写库
项目描述
懒散
Laspy 是一个用于读取、修改和创建 LAS LiDAR 文件的 python 库。
Laspy 与 Python 3.7+ 兼容。
例子
直接读写las
import laspy
las = laspy.read('filename.las')
las.points = las.points[las.classification == 2]
las.write('ground.laz')
打开数据以检查标头(打开仅读取标头和 vlrs)
import laspy
with laspy.open('filename.las') as f:
print(f"Point format: {f.header.point_format}")
print(f"Number of points: {f.header.point_count}")
print(f"Number of vlrs: {len(f.header.vlrs)}")
使用“分块”阅读和写作功能
import laspy
with laspy.open('big.laz') as input_las:
with laspy.open('ground.laz', mode="w", header=input_las.header) as ground_las:
for points in input_las.chunk_iterator(2_000_000):
ground_las.write_points(points[points.classification == 2])
将点附加到现有文件
import laspy
with laspy.open('big.laz') as input_las:
with laspy.open('ground.laz', mode="a") as ground_las:
for points in input_las.chunk_iterator(2_000_000):
ground_las.append_points(points[points.classification == 2])
API 文档和教程可在 ReadTheDocs 获得。
安装
Laspy 可以通过以下方式安装pip:
pip install laspy # without LAZ support
# Or
pip install laspy[laszip] # with LAZ support via LASzip
# Or
pip install laspy[lazrs] # with LAZ support via lazrs