使用pylas.lasmmap读取.LAS文件报错,pylas.read遇内存错误
使用pylas.lasmmap读取LAS文件报错AttributeError,pylas.read报MemoryError
报错信息
Traceback (most recent call last): File "g:\Division Nät\Anläggningar\NAG\VERKSAMHET\Verktyg\Python\Hantera laserdata\test.py", line 35, in <module> las = pylas.lasmmap.LasMMAP(strLAS) File "C:\Users\repa\AppData\Roaming\Python\Python39\site-packages\pylas\lasmmap.py", line 47, in __init__ self.points_data = record.PackedPointRecord.from_buffer( File "C:\Users\repa\AppData\Roaming\Python\Python39\site-packages\pylas\point\record.py", line 282, in from_buffer points_dtype = point_format.dtype AttributeError: 'int' object has no attribute 'dtype' PS G:\Division Nät\Anläggningar\NAG\VERKSAMHET\Verktyg\Python\Hantera laserdata>
我的代码
#import package import pylas.lasmmap #set path path = r'C:/mypath/lasfile.las' #read las las = pylas.lasmmap.lasMMAP(path)
补充情况
尝试用pylas.read读取同一文件时,出现MemoryError。
解决办法
- 先检查并升级pylas版本,旧版本的
LasMMAP处理部分LAS文件(尤其是非标准点格式或超大文件)时存在已知bug:pip install --upgrade pylas - 升级后若仍报错,尝试显式以二进制模式打开文件后传入
LasMMAP,避免默认模式的潜在问题:import pylas.lasmmap path = r'C:/mypath/lasfile.las' with open(path, 'rb') as f: las = pylas.lasmmap.LasMMAP(f) - 针对
MemoryError,LasMMAP本就是为大文件设计的内存映射方案,升级版本后通常可解决;若仍有问题,改用分块读取方式处理:import pylas path = r'C:/mypath/lasfile.las' with pylas.open(path) as f: for points in f.chunk_iterator(1_000_000): # 每次读取100万点 # 在此处理当前块的点数据 print(len(points))
内容的提问来源于stack exchange,提问作者Stackarsmaja
相关产品推荐
相关产品推荐

